![]() this may be an infinite loop depending on availability of dataĨ. then returns all of the data as a string. String serialRead() - runs until there is no more data available in the serial to be read. String getPortDescription() - getter method returning the String containng the port description.ħ. ![]() SerialPort getSerialPort() - returns an object of type SerialPort with the current SerialPortĦ. void setBaudRate(int baud_rate) - sets the baud rate for serial comm.ĥ. void setPortDescription(String portDescription) - setter method to change serial port to which the object is attached.Ĥ. be sure to call this at the end otherwise the port will remain occupiedģ. void closeConnection() - closes connection to serial port. make sure to call this before anything else or exceptions will be thrownĢ. also displays an error message to the user when connection was unsuccessful. returns a boolen depending on whether the connection was successful. boolean openConnection() - opens the connection if portDescription has been initialised. it also sets the baud rate for the serial communication. public Arduino(String portDescription, int baud_rate) - parameterised constructor that initialises the arduino object and sets the communication port to that which has been specified. public Arduino(String portDescription) - parameterised constructor that initialises the arduino object and sets the communication port to that which has been specified.ģ. If this constructor is called, then calling setPortDescription(String portDescription) is essential to set the serial port.Ģ. public Arduino() - empty constructor to be used only if port is unknown and it is imperative to initialise object. Now, you can create an object of Arduino class which will allow you to call serialWrite() and serialRead().ġ. In your class, insert the statement import arduino.* before your class definition.ģ. ![]() ![]() (instructions here: ) (side note: the video does not belong to me)Ģ. Import the 'arduino.jar' file into your buildpath as an external jar. Instructions on set up + documentation of available methods.ġ. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |