/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-library
*
* This example detects the pressed and released events of a button without debounce.
*/
/*
#include <ezButton.h>
ezButton button(4); // create ezButton object that attach to pin 7;
signed long count = 1;
void setup() {
Serial.begin(9600);
Serial.println("Start");
}
void loop() {
button.loop(); // MUST call the loop() function first
if(button.isPressed())
//Serial.println("The button is pressed");
Serial.println(count++);
//if(button.isReleased())
// Serial.println("The button is released");
}
*/
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-library
*
* This example reads the state of a button without debounce and print it to Serial Monitor.
*/
#include <ezButton.h>
ezButton button1(4); // create ezButton object that attach to pin 7;
ezButton button2(5);
signed long count = 1;
int buttonDown = 0;
void setup() {
Serial.begin(9600);
Serial.println("Start");
pinMode(4, INPUT_PULLUP);
}
void loop() {
button1.loop(); // MUST call the loop() function first
button2.loop();
//int btnState = button.getState();
if(button1.getState()!=1)
{
while(button1.getState()!=1)
//while(btnState!=1)// = button.getState())
{
//if(button.isPressed())// && buttonDown == 0)
//if(button.getState()!=1)
//{
//int btnState = button.getState();
if(!digitalRead(4))
{
//if(button1.getState()!=1)
//{
Serial.println(count++);
//buttonDown = 1;
delay(500);
//}
}
}
}
if(button1.getState()!=1 && button2.getState()!=1)
{
while(button1.getState()!=1 && button2.getState()!=1)
//while(btnState!=1)// = button.getState())
{
//if(button.isPressed())// && buttonDown == 0)
//if(button.getState()!=1)
//{
//int btnState = button.getState();
if(!digitalRead(5))
{
//if(button2.getState()!=1)
//{
Serial.println(count++);
//buttonDown = 1;
delay(100);
//}
}
}
}
while(button1.getState()!=1 && button2.getState()!=1)
{
//if(!digitalRead(5))
//{
if(button1.getState()!=1 && button2.getState()!=1)
{
Serial.println(count++);
//buttonDown = 1;
delay(100);
}
//}
//buttonDown = 0;
//while(1);
//}
//else
//{
//buttonDown = 0;
//while(1);
//}
}
//while(button.getState()!=1)
//{
//buttonDown = 0;
//while(1);
//}
/*
if(button.isReleased())// && buttonDown == 0)
{
//Serial.println("The button is released");
//buttonDown = 0;
while(button.getState());
//delay(300);
//buttonDown = 0;
}
//delay(300);
//}
*/
}