Reading data from Arduino
In the previous recipes, we saw how to communicate something to Arduino. In this recipe, we are going to close the recipes about Arduino with the opposite operation—how to read the data that Arduino controls.
Getting ready
Communication with Arduino with the serial port provides mainly three functions:
Serial.read()
Serial.write()
Serial.print()
The first one has already been discussed in the previous recipes, as it is used to communicate commands from Delphi to Arduino. Let's move on to the next two:
Serial.write()
: Writes binary data to the serial port. This data is sent as a byte or a series of bytes in order to send the characters representing the digits of a number to use theprint()
function instead (https://www.arduino.cc/reference/en/language/functions/communication/serial/write/).Serial.print()
: Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are...