Dear all,
I have two relays have been connected to pin D1 and D2, and one pushbutton connected to pin D5
I like to switch D1 on for 30 sec and D2 on for 60 sec, when I push (and release) the pushbutton.
Once pushbutton activated, the D1 and D2 will be off after 30 and 60 sec, respectively.
Please provide an example code. I will follow the sample code to develop my project.
Thanks for your help.
Mike
sounds easy enough.
try blink without delay using different counting for each one.
let us know how it works, or does not work.
simple button concept you can try with just a piece of wire.
//zoomkat LED button test 7-30-2011
int button1 = 4; //button pin, connect to ground to light LED
int press1 = 0;
void setup()
{
pinMode(13, OUTPUT); //LED on pin 13
pinMode(button1, INPUT);
digitalWrite(4, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
digitalWrite(13, HIGH); // set the LED on
delay(2000);
digitalWrite(13, LOW); // set the LED off
}
}