Hey, i have been working on a drink dispenser project for some days now and think i need some help with my code. Currently i have found and edited a code for the projects with 2 water pumps to run for a certain amount, of time which works fine. But i want to implement a wash program for each pump. What i am thinking is that the 2 buttons has two functions each, for example if i press the switch once the pump will start pouring the drink for a certain amount of time, and if i press the same button the wash program will start (only powering the pump on for about 50 seconds to pump water through to wash). Here is the current code.
#include <ezButton.h> // include ezButton library
#include <ezOutput.h> // include ezOutput library
ezOutput pump(2); // create ezOutput object attached to pin 2
ezButton button(A5); // create ezButton object attached to pin A5
void setup() {
Serial.begin(9600);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
pump.low(); // turn pump off
}
void loop() {
pump.loop(); // MUST call the loop() function first
button.loop(); // MUST call the loop() function first
if (button.isPressed()) {
Serial.println("Pump is started");
pump.low();
pump.pulse(10000); // turn on for 10000 milliseconds ~ 10 seconds
// after 10 seconds, pump will be turned off by pump.loop() function
}
}
If anyone has the time to help me out it is very much appreciated