Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

yoreek/Arduino-PushButton

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino PushButton library Build Status

  • Version: 1.0.0
  • Release Date: 2016-01-28

How do I get set up?

  • Download the Latest release from gitHub.
  • Unzip and modify the Folder name to "PushButton".
  • Paste the modified folder on your library folder (On your Libraries folder inside Sketchbooks or Arduino software).
  • Download and Install StateMachine library.
  • Restart the Arduino Software

Usage

#include <Arduino.h>
#include <PushButton.h>

#define BUTTON_PIN 2
#define LED_PIN    13

void pressed(PushButton *, PushButtonState) {
    Serial.println("Button is pressed");
    digitalWrite(LED_PIN, HIGH);
}

void released(PushButton *, PushButtonState) {
    Serial.println("Button is released");
    digitalWrite(LED_PIN, HIGH);
}

void changed(PushButton *, PushButtonState) {
    Serial.println("Button state is changed");
}

PushButton btn(BUTTON_PIN);

void setup() {
    Serial.begin(9600);
    pinMode(BUTTON_PIN, INPUT_PULLUP);
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW);
    btn.onPress(pressed);
    btn.onRelease(released);
    btn.onChange(changed);
}

void loop() {
    btn.loop();

/*
    if (btn.isStateChanged()) {
        if (btn.isPressed()) {
            Serial.println("Button is pressed");
            digitalWrite(LED_PIN, HIGH);
        }
        else {
            Serial.println("Button is released");
            digitalWrite(LED_PIN, LOW);
        }
    }
*/
}

Example

Included on example folder, available on Arduino IDE.

Version History

  • 1.0.0 (2016-01-28): Initial version.

Links

Who do I talk to?

About

Arduino PushButton library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.