I need some help figuring out how to run two functions at the same time. I am trying to have my arduino turn on a set of LEDs for x amount of time, while the arduino counts through some LEDs in order to act like a count down clock. I haven't set up all the countdown LEDs and I plan to use 8 for now. Here is my code:
const int clockledpin1 = 2;
const int clockledpin2 = 3;
const int clockledpin3 = 4;
const int clockledpin4 = 5;
const int clockledpin5 = 6;
const int clockledpin6 = 9;
const int clockledpin7 = 10;
const int clockledpin8 = 11;
const int ledPin = 8;
const int buttonPin = 7;
int buttonState = 0;
void flash() {
digitalWrite(ledPin, HIGH);
delay(900000);
digitalWrite(ledPin, LOW);
}
void ledclock() {
digitalWrite(clockledpin1, HIGH);
delay(60000);
digitalWrite(clockledpin1, LOW);
digitalWrite(clockledpin2, HIGH);
delay(60000);
digitalWrite(clockledpin2, LOW);
digitalWrite(clockledpin3, HIGH);
delay(60000);
digitalWrite(clockledpin3, LOW);
}
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(clockledpin1, OUTPUT);
pinMode(clockledpin2, OUTPUT);
pinMode(clockledpin3, OUTPUT);
pinMode(clockledpin4, OUTPUT);
pinMode(clockledpin5, OUTPUT);
pinMode(clockledpin6, OUTPUT);
pinMode(clockledpin7, OUTPUT);
pinMode(clockledpin8, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
flash();
}
while(ledPin==HIGH){
ledclock();}
}
If someone could tell me what I need to do to make this work, that would be great.