UART (Universal Asynchronous Receiver/Transmitter)
Serial
echo.ino
unsigned char c; // variable to store the received character void setup() { Serial.begin(9600); // setup serial } void loop() { if(Serial.available() > 0){ c = Serial.read(); // read the character Serial.write(c); // echo } }
led_control.ino
unsigned char c; // variable to store the received character int ledPin = 13; void setup() { Serial.begin(9600); // setup serial pinMode(ledPin, OUTPUT); } void loop() { if(Serial.available() > 0){ c = Serial.read(); // read the character if(c == '1'){ digitalWrite(ledPin, HIGH); Serial.println("LED ON..."); }else if(c == '0'){ digitalWrite(ledPin, LOW); Serial.println("LED OFF..."); } } }