//Turn an LED on and off with Arduino and Processing // Origianl Code: ChepeCarlos de ALSW //Update José Manuel Díaz - Fab Academy 2022 int RED = 2; //LED name and corresponding pin boolean statusLed = false; // Two-state variable, false start void setup() { Serial.begin(9600); //Serial communication starts pinMode(RED, OUTPUT); //Red led declared as output digitalWrite(RED, statusLed); //Digital writing according to the LED status variable } void loop() { if (Serial.available()) { //If serial communication is available then... char Letra = Serial.read(); //Communication from letters / literal reading of characters if (Letra == 'a') { statusLed = !statusLed; //If a letter "A" is received, it inverts the state of the LED } digitalWrite(RED, statusLed); //Digital writing according to received data } }