Controlling relay with pushButton
hi,
i'm newbie c++ programing. have attached program gives me errors , have no idea how solve it.
i want activate relay when pushbutton on , deactivate when off (or vice versus). appreciate help.
thank you
i'm newbie c++ programing. have attached program gives me errors , have no idea how solve it.
i want activate relay when pushbutton on , deactivate when off (or vice versus). appreciate help.
thank you
int buttonpin = 5;
int relay = 3;
void setup(){
serial.begin(9600);
pinmode(buttonpin, input);
pinmode(relay, output);
}
void loop(){
boolean buttonstate = digitalread(buttonpin);
serial.print("the button state = ");
serial. println(buttonstate);
if (buttonstate == 0);{digitalwrite(relay, high);}
if (buttonstate == 1); {digitalwrite(relay, low);
}
int relay = 3;
void setup(){
serial.begin(9600);
pinmode(buttonpin, input);
pinmode(relay, output);
}
void loop(){
boolean buttonstate = digitalread(buttonpin);
serial.print("the button state = ");
serial. println(buttonstate);
if (buttonstate == 0);{digitalwrite(relay, high);}
if (buttonstate == 1); {digitalwrite(relay, low);
}
Arduino Forum > Using Arduino > Programming Questions > Controlling relay with pushButton
arduino
Comments
Post a Comment