const int ledPin = 13; // pin the LED is connected to
int mode=0;
void setup()
{
Serial.begin(9600); // Initialize serial port to send and receive at 9600 baud
pinMode(ledPin, OUTPUT); // set this pin as output
}
void loop()
{
if ( Serial.available()) // Check to see if at least one character is available
{
char ch = Serial.read();
if (ch =='1')
{
mode=1;
}
if(ch=='0'){
mode=0;
}
}
bulb();
}
void bulb(){
digitalWrite(ledPin,mode);
}