int red = 14; int yellow = 9; int blue = 5; void setup() { pinMode(blue, OUTPUT); //set pin as output , blue led pinMode(red, OUTPUT); //set pin as output , red led pinMode(yellow, OUTPUT); //set pin as output , yellow led Serial.begin(9600); //start serial communication @9600 bps } void loop(){ if(Serial.available()){ //id data is available to read char val = Serial.read(); if(val == 'r'){ //if r received digitalWrite(red, HIGH); //turn on red led } if(val == 'b'){ //if b received digitalWrite(blue, HIGH); //turn on blue led } if(val == 'y'){ //if y received digitalWrite(yellow, HIGH); //turn on yellow led } if(val == 'f'){ //if f received digitalWrite(red, LOW); //turn off all led digitalWrite(yellow, LOW); digitalWrite(blue, LOW); } } }