Skip to content

Instantly share code, notes, and snippets.

@fasmide
Last active December 27, 2015 01:48
Show Gist options
  • Save fasmide/7247207 to your computer and use it in GitHub Desktop.
Save fasmide/7247207 to your computer and use it in GitHub Desktop.
box
#include <Bounce.h>
#include <LiquidCrystal.h>
#define LARGEBTN 10
#define SMALLBTN 11
#define BUZZER 9
Bounce largeBouncer = Bounce( LARGEBTN, 35 );
Bounce smallBouncer = Bounce( SMALLBTN, 5);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);
char lastChar;
unsigned long lastCharTime = 0;
void setup() {
pinMode(LARGEBTN,INPUT);
pinMode(SMALLBTN, INPUT);
pinMode(BUZZER, OUTPUT);
Serial.begin(115200);
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Booting");
lcd.setCursor(0,1);
lcd.print("Anti Facerape!");
}
void loop() {
// Update the debouncer
largeBouncer.update();
smallBouncer.update();
int value = largeBouncer.risingEdge();
if ( value == HIGH) {
Serial.println("large");
//sound();
}
value = smallBouncer.risingEdge();
if(value == HIGH) {
Serial.println("small");
//sound();
}
handleLcd();
}
void handleLcd()
{
if (Serial.available()) {
if(millis() - lastCharTime > 100) {
lcd.clear();
}
lastChar = Serial.read();
if(lastChar == 10) // 10 == newline
{
lcd.setCursor(0,1);
} else {
lcd.write(lastChar);
}
lastCharTime = millis();
}
}
void sound()
{
digitalWrite(BUZZER, HIGH);
delay(100);
digitalWrite(BUZZER, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment