Hey. I am setting up a device where i need to blink leds for number of minutes if button is pressed. And other blinks aswell. What is the best option to run diffrent (if) commands for number of minutes?
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 10; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
// the loop function runs over and over again forever
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(60); // off/on
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(60); // off/on
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}