int val = 0; void setup() { Serial.begin(9600); // Turn on LED when program starts pinMode(13, OUTPUT); } void loop() { if(Serial.available()){ val = Serial.read(); } if(val == 1){ digitalWrite(13, HIGH); }else if(val == 0){ digitalWrite(13, LOW); } }