Created
January 19, 2016 02:50
-
-
Save dcmoore/7c711c8e1a2394cad9c0 to your computer and use it in GitHub Desktop.
Crystal Ball exercise from the Arduino Projects Book with my little twist on the answers.
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 previousSwitchState = 0; | |
int reply; | |
void setup() { | |
lcd.begin(16, 2); | |
pinMode(switchPin, INPUT); | |
lcd.print("What it do?"); | |
} | |
void loop() { | |
switchState = digitalRead(switchPin); | |
if (switchState != previousSwitchState) { | |
if (switchState == LOW) { | |
reply = random(8); | |
lcd.clear(); | |
lcd.setCursor(0, 0); | |
lcd.print("You in foe it: "); | |
lcd.setCursor(0, 1); | |
switch(reply) { | |
case 0: | |
lcd.print("Hell naw"); | |
break; | |
case 1: | |
lcd.print("Stupid question"); | |
break; | |
case 2: | |
lcd.print("Foe show"); | |
break; | |
case 3: | |
lcd.print("That ain shit"); | |
break; | |
case 4: | |
lcd.print("You dumb"); | |
break; | |
case 5: | |
lcd.print("It ain like dat"); | |
break; | |
case 6: | |
lcd.print("Iunno"); | |
break; | |
case 7: | |
lcd.print("Biggity bitch"); | |
break; | |
} | |
} | |
} | |
previousSwitchState = switchState; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment