const int buttonPin = 0; // the number of the pushbutton pin const int ledPin1 = 1; // the number of the LED pin const int ledPin2 = 2; // the number of the LED pin const int ledPin3 = 3; // the number of the LED pin int incomingByte = 0; // variables will change: int buttonState = 0; // variable for reading the pushbutton status int buttonCount = 0; int delay_interval = 0; void setup() { Serial.begin(115200); // initialize the LED pin as an output: pinMode(ledPin1, OUTPUT); // initialize the pushbutton pin as an input: pinMode(ledPin2, OUTPUT); // initialize the pushbutton pin as an input: pinMode(ledPin3, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT_PULLUP); } void loop() { // send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read(); Serial.print("I received: "); Serial.println((char)incomingByte, DEC); } if ( incomingByte == '0') { //do nothing } else if ( incomingByte == '1') { digitalWrite(ledPin1, HIGH); // turn on LED1 } else if (incomingByte == '2') { digitalWrite(ledPin2, HIGH); } else if (incomingByte == '3') { digitalWrite(ledPin3, HIGH); } else if ( incomingByte == '4') { digitalWrite(ledPin1, LOW); } else if (incomingByte == '5') { digitalWrite(ledPin2, LOW); } else if (incomingByte == '6') { digitalWrite(ledPin3, LOW); } else if (incomingByte == '9') { digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, LOW); } else { } } // say what you got: // Serial.print("I received: "); // Serial.println(incomingByte, DEC); // }