Hello,
I am working on a little project for school and need some help.
First part of project is done and working but I am missing part with third button.
So I have a pulldown buttons and I need to hold buttonpin3 for 3 sec and LED has to turn on, it has to be done using millis.
Here is one part of project:
int LED = 5;
int buttonpin1= 8;
int buttonpin2 = 9;
int buttonpin3= 10;
int buttonState1= 0;
int buttonState2= 0;
int buttonState3= 0;
Welcome to the forum. I hope you stick with Arduino long after this assignment and come back here often for help and to help others. Can you try to write the 3rd button logic using your own words? Let's see your best effort at it and I don't have any problem helping with syntax or code.
Try to understand how Blink Without Delay works. millis() basically "runs forever" so you just grab snapshots of the millis() time every time through the loop and subtract & compare to see how much time has passed.
Of course there is only one currentMillis but you can have multiple intervals (such as interval1 & interval2) and you can have multiple-associated previousMillis (such as previousMillis1 & previousMillis(2).
Or you can use more descriptive variable names, so if you have red & green LEDs you can have intervalRed & intervalGreen, etc.
Thanks,
So when the LED is off I need to press button 3 and hold it. After 3 sec of holding the button, LED has to turn on. After the LED turns on, button can be released and LED has to stay on.