boolean buttonPressed[2];
String jeff;
long LastTime = 0;
long HowLong;
int nbrOfButtons = 3;
int debounceTime = 300;
long lastReadTime = 0;
void setup() {
// put your setup code here, to run once:
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("Hello World");
buttonPressed[0] = 1;
buttonPressed[1] = 1;
buttonPressed[2] = 1;
}
void loop() {
// put your main code here, to run repeatedly:
if ( (millis() - lastReadTime) > debounceTime ) {
lastReadTime = millis();
// read all buttons here e.g.
for( byte i=0; i<nbrOfButtons; i++ ) {
buttonPressed[i] = digitalRead(i+4);
// you can do edge detection here if necessary
}
if (buttonPressed[0] == 0) {
Serial.println("Button 1 is Pressed");
HowLong = (millis() - LastTime);
LastTime = millis();
Serial.print("Last Press was ");
Serial.print(HowLong / 1000);
Serial.println(" Seconds Ago"); }}
if (buttonPressed[1] == 0) {
Serial.println("Button 2 is Pressed");}
if (buttonPressed[2] == 0) {
Serial.println("Button 3 is Pressed");}
delay(100);
}