JChristensen / JC_Button

Arduino library to debounce button switches, detect presses, releases, and long presses
GNU General Public License v3.0
425 stars 102 forks source link

Hello Jack Christensen #5

Closed ludo5959 closed 7 years ago

ludo5959 commented 7 years ago

Many thancks , for your work and of course your help for beginner. j m front of your job about your button programe

include //https://github.com/JChristensen/Button

define int BUTTON_PIN 2 //Connect a tactile button switch (or something similar)

                       //from Arduino pin 2 to ground.

define int PULLUP true //To keep things simple, we use the Arduino's internal pullup resistor.

define int 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 int DEBOUNCE_MS 20 //A debounce time of 20 milliseconds usually works well for tactile button switches.

define LED_PIN 13 //The standard Arduino "Pin 13" LED

Button myBtn(2,true, true, 20); //Declare the button

boolean ledState; //A variable that keeps the current LED status

void setup(void)

{

pinMode(LED_PIN, OUTPUT);    //Set the LED pin as an output

}

void loop(void)

{

myBtn.read();                    //Read the button

if (myBtn.wasReleased()) {       //If the button was released, change the LED state

    ledState = !ledState;

    digitalWrite(LED_PIN, ledState);

}

} it doesnt work , j get your button librairie in my blilio. please may you help me

JChristensen commented 7 years ago

Please raise issues here only for actual problems with the library, not for problems with your code. Please use the Arduino forum or similar site for help with your code.