Created
February 6, 2017 20:11
-
-
Save loftywaif002/537325166ae4194cb13db02921c9bbdb to your computer and use it in GitHub Desktop.
This file contains 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 <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
const int switchPin = 6; | |
int switchState = 0; | |
int prevSwitchState = 0 ; | |
int reply; | |
void setup(){ | |
lcd.begin(16,2); | |
pinMode(switchPin,INPUT); | |
lcd.print("Ask the,"); | |
lcd.setCursor(0,1); | |
lcd.print("Crystal Ball!"); | |
} | |
void loop(){ | |
switchState = digitalRead(switchPin); | |
if(switchState != prevSwitchState){ | |
if(switchState==LOW){ | |
reply = random(8); | |
lcd.clear(); | |
lcd.setCursor(0,0); | |
lcd.print("The Ball Says: "); | |
lcd.setCursor(0,1); | |
switch(reply){ | |
case 0: | |
lcd.print("Tomorrow never dies"); | |
break; | |
case 1: | |
lcd.print("Be Hopeful"); | |
break; | |
case 2: | |
lcd.print("Green is your color"); | |
break; | |
case 3: | |
lcd.print("Think before you do"); | |
break; | |
case 4: | |
lcd.print("It is your lucky day"); | |
break; | |
case 5: | |
lcd.print("Be positive"); | |
break; | |
case 6: | |
lcd.print("expect money today"); | |
break; | |
case 7: | |
lcd.print("Hi"); | |
break; | |
} | |
} | |
} | |
prevSwitchState = switchState; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment