int outPin = 1; void setup(){ pinMode(outPin,OUTPUT); Serial.begin(112500); Serial.println("Enter 1 or 0"); } void loop(){ if(Serial.available()>0) { char ch = Serial.read(); if (ch == '1') { digitalWrite(outPin,1); } else if (ch == '0') { digitalWrite(outPin,LOW); } } }