Rename library & repository from Button to JC_Button.
This commit is contained in:
@@ -15,21 +15,20 @@
|
||||
* San Francisco, California, 94105, USA. *
|
||||
*----------------------------------------------------------------------*/
|
||||
|
||||
#include <Button.h> //https://github.com/JChristensen/Button
|
||||
#include <JC_Button.h> //https://github.com/JChristensen/JC_Button
|
||||
|
||||
#define BUTTON_PIN 2 //Connect a tactile button switch (or something similar)
|
||||
//from Arduino pin 2 to ground.
|
||||
#define BUTTON_PIN 7 //Connect a tactile button switch (or something similar) from this pin to ground.
|
||||
#define PULLUP true //To keep things simple, we use the Arduino's internal pullup resistor.
|
||||
#define INVERT true //Since the pullup resistor will keep the pin high unless the
|
||||
//switch is closed, this is negative logic, i.e. a high state
|
||||
//means the button is NOT pressed. (Assuming a normally open switch.)
|
||||
#define DEBOUNCE_MS 20 //A debounce time of 20 milliseconds usually works well for tactile button switches.
|
||||
#define DEBOUNCE_MS 25 //A debounce time of 20 milliseconds usually works well for tactile button switches.
|
||||
|
||||
#define LED_PIN 13 //The standard Arduino "Pin 13" LED.
|
||||
#define LONG_PRESS 1000 //We define a "long press" to be 1000 milliseconds.
|
||||
#define BLINK_INTERVAL 100 //In the BLINK state, switch the LED every 100 milliseconds.
|
||||
|
||||
Button myBtn(BUTTON_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Declare the button
|
||||
Button myBtn(BUTTON_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Define the button
|
||||
|
||||
//The list of possible states for the state machine. This state machine has a fixed
|
||||
//sequence of states, i.e. ONOFF --> TO_BLINK --> BLINK --> TO_ONOFF --> ONOFF
|
||||
@@ -41,12 +40,12 @@ boolean ledState; //The current LED status
|
||||
unsigned long ms; //The current time from millis()
|
||||
unsigned long msLast; //The last time the LED was switched
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED_PIN, OUTPUT); //Set the LED pin as an output
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
ms = millis(); //record the current time
|
||||
myBtn.read(); //Read the button
|
||||
|
||||
@@ -12,26 +12,25 @@
|
||||
* San Francisco, California, 94105, USA. *
|
||||
*----------------------------------------------------------------------*/
|
||||
|
||||
#include <Button.h> //https://github.com/JChristensen/Button
|
||||
#include <JC_Button.h> //https://github.com/JChristensen/JC_Button
|
||||
|
||||
#define BUTTON_PIN 2 //Connect a tactile button switch (or something similar)
|
||||
//from Arduino pin 2 to ground.
|
||||
#define BUTTON_PIN 7 //Connect a tactile button switch (or something similar) from this pin to ground.
|
||||
#define PULLUP true //To keep things simple, we use the Arduino's internal pullup resistor.
|
||||
#define INVERT true //Since the pullup resistor will keep the pin high unless the
|
||||
//switch is closed, this is negative logic, i.e. a high state
|
||||
//means the button is NOT pressed. (Assuming a normally open switch.)
|
||||
#define DEBOUNCE_MS 20 //A debounce time of 20 milliseconds usually works well for tactile button switches.
|
||||
#define DEBOUNCE_MS 25 //A debounce time of 25 milliseconds usually works well for tactile button switches.
|
||||
#define LED_PIN 13 //The standard Arduino "Pin 13" LED
|
||||
|
||||
Button myBtn(BUTTON_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Declare the button
|
||||
Button myBtn(BUTTON_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Define the button
|
||||
boolean ledState; //A variable that keeps the current LED status
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED_PIN, OUTPUT); //Set the LED pin as an output
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
myBtn.read(); //Read the button
|
||||
|
||||
|
||||
@@ -13,22 +13,22 @@
|
||||
* San Francisco, California, 94105, USA. *
|
||||
*----------------------------------------------------------------------*/
|
||||
|
||||
#include <Button.h> //https://github.com/JChristensen/Button
|
||||
#include <JC_Button.h> //https://github.com/JChristensen/JC_Button
|
||||
|
||||
#define DN_PIN 2 //Connect two tactile button switches (or something similar)
|
||||
#define UP_PIN 3 //from Arduino pin 2 to ground and from pin 3 to ground.
|
||||
#define DN_PIN 7 //Connect two tactile button switches (or something similar)
|
||||
#define UP_PIN 8 //from Arduino pin 7 to ground and from pin 8 to ground.
|
||||
#define PULLUP true //To keep things simple, we use the Arduino's internal pullup resistor.
|
||||
#define INVERT true //Since the pullup resistor will keep the pin high unless the
|
||||
//switch is closed, this is negative logic, i.e. a high state
|
||||
//means the button is NOT pressed. (Assuming a normally open switch.)
|
||||
#define DEBOUNCE_MS 20 //A debounce time of 20 milliseconds usually works well for tactile button switches.
|
||||
#define DEBOUNCE_MS 25 //A debounce time of 20 milliseconds usually works well for tactile button switches.
|
||||
|
||||
#define REPEAT_FIRST 500 //ms required before repeating on long press
|
||||
#define REPEAT_INCR 100 //repeat interval for long press
|
||||
#define MIN_COUNT 0
|
||||
#define MAX_COUNT 59
|
||||
|
||||
Button btnUP(UP_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Declare the buttons
|
||||
Button btnUP(UP_PIN, PULLUP, INVERT, DEBOUNCE_MS); //Define the buttons
|
||||
Button btnDN(DN_PIN, PULLUP, INVERT, DEBOUNCE_MS);
|
||||
|
||||
enum {WAIT, INCR, DECR}; //The possible states for the state machine
|
||||
@@ -37,12 +37,12 @@ int count; //The number that is adjusted
|
||||
int lastCount = -1; //Previous value of count (initialized to ensure it's different when the sketch starts)
|
||||
unsigned long rpt = REPEAT_FIRST; //A variable time that is used to drive the repeats for long presses
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
btnUP.read(); //read the buttons
|
||||
btnDN.read();
|
||||
|
||||
Reference in New Issue
Block a user