int Right = 2; int Left = 3; // define two digital pins char PinState; void setup() { // put your setup code here, to run once: pinMode(Right,OUTPUT); pinMode(Left,OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if(Serial.available() > 0) //if some date is avaliabe in serial port PinState = Serial.read(); //read the vaule if(PinState == '1'){ //if statement will be 1 digitalWrite(Right,HIGH); digitalWrite(Left,LOW); } if(PinState == '0'){ //if statement will be 0 digitalWrite(Right,LOW); digitalWrite(Left,HIGH); } if(PinState == '2'){ //if statement will be 2 digitalWrite(Right,LOW); digitalWrite(Left,LOW); } }