Skip to content
Browse files

change to use the bouncing library, update code to use buzzer and led…

… like kakemans said
  • Loading branch information...
1 parent 5ec5ccf commit d46b080b0aaadbe954b0db92b8bbd74003b1d955 @sweemeng committed Apr 21, 2011
Showing with 19 additions and 7 deletions.
  1. +19 −7 storybox/storybox.pde
View
26 storybox/storybox.pde
@@ -1,11 +1,17 @@
#include <LCD4Bit_mod.h>
#include <EEPROM.h>
-#include <Button.h>
+
#include <WordStorage.h>
#include <TrueRandom.h>
+#include <Bounce.h>
+
+#define button1 2
+#define lcdBacklit 3
+#define buzzer 10
+#define statusLed 13
LCD4Bit_mod lcd = LCD4Bit_mod(2);
-Button button = Button(2,PULLDOWN);
+Bounce bouncer = Bounce(button1,50);
WordStorage storage;
long randno;
@@ -20,23 +26,29 @@ void setup() {
randomSeed(analogRead(0));
Serial.begin(9600);
init_word();
+ pinMode(statusLed,OUTPUT);
+ pinMode(buzzer,OUTPUT);
+ pinMode(button1,INPUT);
+ pinMode(lcdBacklit,OUTPUT);
}
void loop(){
+ bouncer.update();
+ int value = bouncer.read()
lcd.clear();
char words;
- if(button.isPressed()){
- digitalWrite(13,HIGH);
- digitalWrite(10,HIGH);
+ if(value == HIGH){
+ digitalWrite(statusLed,HIGH);
+ digitalWrite(buzzer,HIGH);
randno = TrueRandom.random(SIZE);
Serial.println(randno);
print_clear();
get_word(randno);
delay(500);
}else{
- digitalWrite(13,LOW);
- digitalWrite(10,LOW);
+ digitalWrite(statusLed,LOW);
+ digitalWrite(buzzer,LOW);
}
}

0 comments on commit d46b080

Please sign in to comment.
Something went wrong with that request. Please try again.