...
The corresponding baud rate must be selected in the serial monitor to display information and then the data is displayed. The monitor looks like this.
Call Response
This example will send back over serial everything it receives until it finds a line break symbol.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
String inData;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
}
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved; // Process message when new line character is recieved
if (recieved == '\n')
{
Serial.print("I got : ");
Serial.println(inData);
inData = ""; // Clear recieved buffer
delay(1000);
}
}
} |
Further Information
Serial - The Arduino reference page
...