Echo

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 ...

Get Mastering Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.