An echo application will read the text in from the Serial Monitor and will then output it back.
The text will be entered into the input field, as shown in the following screenshot:
And the text will be echoed, as shown in the following screenshot:
We will start off by creating a new sketch and add the following code to it:
byte bytesIn; void setup() { Serial.begin(9600); } void loop() { if (Serial.available()) { bytesIn = Serial.read(); Serial.write(bytesIn); } }
In this code, we start off by defining a variable named bytesIn of the byte type. Then within the setup() function the data rate for the serial data transmission is set to 9600 baud.
Within the loop() function we use the Serial.available() function to see if there is any data stored in the serial queue. The Serial.available() function returns the number of bytes available for reading...