Created
January 27, 2015 05:20
-
-
Save systemsoverload/cb9600943713dbfe8103 to your computer and use it in GitHub Desktop.
Simple program to count button presses and display them on a 16x2 LCD screen with TeensyDuino libraries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Bounce.h> | |
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
const int buttonPin = 23; | |
Bounce pushbutton = Bounce(buttonPin, 10); // 10 ms debounce | |
byte previousState = HIGH; | |
unsigned int count = 0; | |
void setup() { | |
pinMode(buttonPin, INPUT_PULLUP); | |
lcd.begin(16, 2); | |
lcd.print("Button Presses:"); | |
} | |
void loop() { | |
if (pushbutton.update()) { | |
if (pushbutton.fallingEdge()) { | |
count = count + 1; | |
} | |
} else { | |
lcd.setCursor(0, 1); | |
lcd.print(count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment