Hey, it is an Arduino UNO and here is an approach I tried from one of the other comments, it doesn't work but I hope you can understand what I mean with like monitor simultaneously.
(basically the arduino is constantly checking the potentioemters value - which simulates a switch since I don't have one - and depending on the state one of two modes runs)
int redLED = 3;
int blueLED = 4;
int button = 6;
int buzzer = 5;
long starttime = 0;
long endtime = 0;
void setup() {
Serial.begin(9600); //remove when end
pinMode(A0, INPUT); //potentiometer
pinMode(buzzer, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(blueLED, OUTPUT);
pinMode(button, INPUT_PULLUP);
digitalWrite(redLED, LOW); //initialize all these as off, LEDs as well as we need to see in the void loop which one will be turne on
digitalWrite(blueLED, LOW);
digitalWrite(buzzer, LOW);
}
void loop() {
Serial.println(analogRead(A0));
if (analogRead(A0) >= 512) {
auto2();
}
else if (analogRead(A0) < 512){
manual();
}
}
void auto2(){
//depending on if manual or auto, have either one or the other LED on
while (digitalRead(button) == HIGH){ //while loop that stops everything until user presses the button to start
}
digitalWrite(buzzer, HIGH);
delay(50); //delay required between while loops or the LOW state that breaks each loop will affect both and will not start the light flashing loop
digitalWrite(buzzer, LOW);
while (1==1){ //while loop that stops everything until user presses the button to start
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
starttime = millis();
endtime = starttime;
while ((endtime - starttime) <=20000) // do this loop for up to 1000mS = 1S, 20x60x1000=1200
{
digitalWrite(redLED, LOW);
delay(500);
digitalWrite(redLED, HIGH);
delay(500);
endtime = millis();
}
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
starttime = millis();
endtime = starttime;
while ((endtime - starttime) <=5000) // do this loop for up to 1000mS = 1S
{
digitalWrite(redLED, HIGH);
endtime = millis();
}
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
digitalWrite(redLED, LOW);
delay(50);
}
}
void manual(){
//depending on if manual or auto, have either one or the other LED on
digitalWrite(blueLED, HIGH);
while (digitalRead(button) == HIGH){ //while loop that stops everything until user presses the button to start
}
digitalWrite(buzzer, HIGH);
delay(50); //delay required between while loops or the LOW state that breaks each loop will affect both and will not start the light flashing loop
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
starttime = millis();
endtime = starttime;
while ((endtime - starttime) <=1200000) // do this loop for up to 1000mS = 1S, 20x60x1000=1200
{
digitalWrite(blueLED, LOW);
delay(500);
digitalWrite(blueLED, HIGH);
delay(500);
endtime = millis();
}
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
while (digitalRead(button) == HIGH){ //while loop that stops everything until user presses the button to start
}
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
starttime = millis();
endtime = starttime;
while ((endtime - starttime) <=20000) // do this loop for up to 1000mS = 1S
{
digitalWrite(blueLED, HIGH);
endtime = millis();
}
digitalWrite(buzzer, HIGH);
digitalWrite(blueLED, LOW);
delay(500);
digitalWrite(buzzer, LOW);
}