In relay Off condition
Arduino Code is
const int pin =13;
void setup(){
pinMode(pin,OUTPUT);
Serial.begin(9600);
Serial.println("Please enter a char");
}
void loop(){
Serial.println("Please enter y to ON and n to OFF led");
while(!Serial.available())
{
//wait until user enters the data
}
char input;
if(Serial.available())
{
Serial.println(input = Serial.read());
if(input == 'y'){
Serial.println("you entered y led is ON");
digitalWrite(pin,HIGH);
}
else if(input == 'n'){
Serial.println("you entered n led is OFF");
digitalWrite(pin,LOW);
}
else{
Serial.println("you entered a wrong character");
}
}
}
No comments:
Post a Comment