I am on here looking for some help regarding some programming that I am trying to achieve. I am trying to achieve 2 buttons (1 for hours, 1 for minutes) that can be set at a desired time, once set both buttons are to be pressed together to begin the timer. This is all connected to the Oled display that will display the numbers and time in a "00:00" format. This is my current code for one button but I am unsure where to go from here or if this is the best way to have done this. Help with this and how to write it for the outcome I am trying to achieve would be greatly appreciated. I have copied what I have done so far below.
Below is a start. You can code the function that tests to see whether a button has been pressed to return a boolean value. It's nice because it makes the code more readable and you can store that value in order to check to see if one or both buttons are pressed at the same time. Just duplicate for hour button and minute button.
#include <ezButton.h>
ezButton button1(6); // create Button object that attach to pin 6;
ezButton button2(7); // create Button object that attach to pin 7;
void setup() {
Serial.begin(9600);
button1.setDebounceTime(50); // set debounce time to 50 milliseconds
button2.setDebounceTime(50); // set debounce time to 50 milliseconds
button1.setCountMode(COUNT_FALLING);
button2.setCountMode(COUNT_FALLING);
}
void loop() {
button1.loop(); // MUST call the loop() function first
button2.loop(); // MUST call the loop() function first
unsigned long btn1Count = button1.getCount();
unsigned long btn2Count = button2.getCount();
Serial.print("button 1 count: ");
Serial.println(btn1Count);
Serial.print("button 2 count: ");
Serial.println(btn2Count);
}