I'm just trying to get the very basics of serial communication started; I'm trying to use this example I found, from what I understand it should be working. I just want what I type into the serial monitor to be output back, so I can see how it works. I also tried removing the while serial.available in case the serial monitor doesn't trigger that condition. Here is my code:
// Buffer to store incoming commands from serial port
String inData;
void setup() {
Serial.begin(9600);
Serial.println("Initialized\n");
}
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved;
// Process message when new line character is recieved
if (recieved == '\n')
{
Serial.println("Arduino Received: ");
Serial.println(inData);
inData = ""; // Clear recieved buffer
}
}
}
It currently uploads fine, and prints "initialized" but doesn't work if i try to "send" any data.
received
as soon as you read it? – Dan12-16