So from looking at that, I think I understand some of it, but there are definitely parts I am confused about.
I changed the code to:
//LEDS
const int LED_ACT = 9; //LED_ACTION pin#
const int LED_POUR = 11; //LED_POUR_NOW pin#
//BUTTONS
const int CHEM = 2; //BUTTON 1 pin#
const int WAVE = 7; //BUTTON 2 pin#
const int SOLO = 4; //BUTTON 3 pin#
//LED Intervals
const int BLOOM = 60000;
const int PULSE = 15000;
const int BREW = 240000;
const int SERVE = 0;
//LED Blink Durations
const int blinkDuration = 500;
//Variables
byte LED_ACT_State = LOW;
byte LED_POUR_State = LOW;
//STORE VALUES OF ITERATIONS IN LOOP
unsigned long currentMillis = 0;
unsigned long previousLED_ACTMillis = 0; // will store last time the LED was updated
unsigned long previousLED_POURMillis = 0; // will store last time the LED was updated
//WHEN BUTTON WAS LAST PRESSED
unsigned long previousButtonMillis = 0;
void setup() {
Serial.begin(9600); //SETS SERIAL CONNECTION SPEED
Serial.println("Midterm"); //LOOK IN CONSOLE FOR SKETCH NAME
pinMode(LED_ACT,OUTPUT); //LED setup as output
pinMode(LED_POUR,OUTPUT); //LED setup as output
pinMode(CHEM,INPUT); //BUTTON1 setup as input
pinMode(WAVE,INPUT); //BUTTON2 setup as input
pinMode(SOLO,INPUT); //BUTTON3 setup as input
// pinMode(SOUND, OUTPUT); //Piezo set up as Output
}
void loop() {
currentMillis = millis(); // capture the latest value of millis()
// this is equivalent to noting the time from a clock
// use the same time for all LED flashes to keep them synchronized
readCHEM ();
updateLED_ACT_State ();
updateLED_POUR_State ();
}
void readCHEM(BLOOM, PULSE, PULSE, PULSE, PULSE) {
if(millis() - previousButtonMillis >= SERVE) {
if (digitalRead(CHEM)==LOW) {
digitalWrite(LED_ACT, LOW);
LED_ACT_STATE = !LED_ACT_STATE
previousButtonMillis += SERVE;
}
}
}
This last part - the function of running the action reading the button CHEM. When the button is pressed, I want it to perform the same as it did in the previous post:
digitalWrite(LED, LOW); //GET READY
delay(500);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW); //GET SET
delay(500);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW); //GO!
delay(500);
digitalWrite(LED, HIGH); //Bloom 50g
delay(60000);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH); //First Pulse 200g (250g)
delay(14500);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH); //Second Pulse 50g (300g)
delay(14500);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH); //Third Pulse 50g (350g)
delay(14500);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH); //Forth Pulse 65g (415g)
delay(14500);
digitalWrite(LED, LOW); //Flash 1
delay(500);
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW); //Flash 2
delay(500);
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW); //Flash 3
delay(500);
digitalWrite(LED, HIGH);
delay(500);
But I am having a tough time understanding the logic of the post you pointed out to make the LED work in the same way. As it is now, the LED is just constantly on and I haven't been able to debug the problem!