You are on page 1of 13

#include <LiquidCrystal.

h> //define Liquid Crystal library


LiquidCrystal lcd(12,11,5,4,3,2); //define ports for lcd
const int buzzerPin = 1; //define buzzerPin
const int songLength = 33; //define song length
char notes[] = "gCgcgCggCgCE DCbaXgCgcgCgC agfedc "; //notes for the song
int beats[] = {2,2,2,2,2,2,4,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,4,2,1,1,2,2,2,2,2}; //beats for the song
int tempo = 225; //tempo for song
#define CHOICE_NONE 0 //defdine choice none
#define CHOICE_A (1 << 0) //define choice A
#define CHOICE_B (1 << 1) //define choice B
#define CHOICE_C (1 << 2) //define choice C
#define CHOICE_D (1 << 3) //define choice D
#define answerAPin 10 //define port for answer A
#define answerBPin 9 //define port for answer B
#define answerCPin 8 //define port for answer C
#define answerDPin 7 //define port for answer D
int questionAsked; //define question asked
void setup() {
pinMode(buzzerPin, OUTPUT); //define buzzer pin as output
pinMode(answerAPin, INPUT_PULLUP); //define answer a as input
pinMode(answerBPin, INPUT_PULLUP); //define answer b as input
pinMode(answerCPin, INPUT_PULLUP); //define answer c as input
pinMode(answerDPin, INPUT_PULLUP); //define answer d as input
lcd.begin(16,2); //set lcd size at 16 by 2
lcd.clear(); //clear the lcd
if(checkButton() == CHOICE_NONE) //if there is no button pressed then do the following
{
lcd.print("Welcome to Jeopardy!"); //lcd will print Welcome to Jeopardy
for (int positionCounter = 0; positionCounter < 19; positionCounter++) { //writing on the screen
will scroll to the left every .275 seconds
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500); //wait 2.5 seconds
}
lcd.clear();
randomSeed(analogRead(0)); //sets up the randomizer function

{
lcd.clear();
lcd.print("How much in a bakers dozen?");
delay(1000);
for (int positionCounter = 0; positionCounter < 38; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);
lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("12");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("18");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("13");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("1");
delay(500);
lcd.clear();
delay(500);

int i, duration; //play the notes defined earlier


for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}

else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_C) //if answer C is chosen, print Correct
{
lcd.print("Correct");
}
else //else print Incorrect
{
lcd.print("Incorrect");
}
delay(2000);
lcd.clear();
}
{
lcd.clear();
lcd.print("How many quarts in a gallon?");
delay(1000);
for (int positionCounter = 0; positionCounter < 64; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);
lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("2");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("4");
delay(2000);
lcd.clear();

lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("17");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("3");
delay(500);
lcd.clear();
delay(500);
int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_B)
{
lcd.print("Correct");
}
else
{
lcd.print("Incorrect");
}
delay(2000);
lcd.clear();
}

{
lcd.clear();
lcd.print("What sound do cows make?");
delay(1000);
for (int positionCounter = 0; positionCounter < 64; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);
lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("Milk");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("Oink");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("Neigh");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("Moo");
delay(500);
lcd.clear();
delay(500);

int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);

}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_D)
{
lcd.print("Correct");
}
else
{
lcd.print("Incorrect");
}
delay(2500);
lcd.clear();
}
}
void loop() {
lcd.print("Welcome to MLG JEOPARDY!!!");
for (int positionCounter = 0; positionCounter < 19; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
questionAsked = (random(10)); //generate a random number between 0 and 4

if (questionAsked = 1) //if the number generated is 1, then run the following code
{
lcd.clear();
lcd.print("What is the dankest meme?");
delay(1000);
for (int positionCounter = 0; positionCounter < 64; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);

lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("Pepe");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("Doge");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("Xx_Illuminati_xX");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("Ur mum");
delay(500);
lcd.clear();
delay(500);
int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_A)

{
lcd.print("Ur not dumb");
}
else
{
lcd.print("Ur trash m8!!!");
}
delay(2000);
lcd.clear();
}
if(questionAsked = 0);{
lcd.clear();
lcd.print("What is a meme?");
delay(1000);
for (int positionCounter = 0; positionCounter < 60; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);
lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("2 much dank");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("Pic w/ caption");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("Savagrey");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("MLG roasts");

delay(500);
lcd.clear();
delay(500);
int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_A)
{
lcd.print("Ur not dumb");
}
else
{
lcd.print("Ur dumb m8!!!");
}
delay(2000);
lcd.clear();
}
if (questionAsked = 2)
{
lcd.clear();
lcd.print("Who was the original dank meme?");
delay(1000);
for (int positionCounter = 0; positionCounter < 64; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);

lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("Troll");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("Roflcopter");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("u mad bro");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("Alfred E. Neuman");
delay(500);
lcd.clear();
delay(500);
int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}
delay(750);
if (checkButton() == CHOICE_D)

{
lcd.print("Ur not trash");
}
else
{
lcd.print("Ur dumb m8!!!");
}
delay(2000);
lcd.clear();
}
if (questionAsked = 3)
{
lcd.clear();
lcd.print("What sound do cows make?");
delay(1000);
for (int positionCounter = 0; positionCounter < 64; positionCounter++) {
lcd.scrollDisplayLeft();
delay(275);
}
delay(2500);
lcd.clear();
lcd.print("A.");
lcd.setCursor(0,1);
lcd.print("Milk");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("B.");
lcd.setCursor(0,1);
lcd.print("Oink");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("C.");
lcd.setCursor(0,1);
lcd.print("Neigh");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("D.");
lcd.setCursor(0,1);
lcd.print("Moo");
delay(500);

lcd.clear();
delay(500);
int i, duration;
for (i = 0; i < songLength; i++)
{
duration = beats[i] * tempo;
if (notes[i] == ' ')
{
delay(duration);
}
else
{
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration);
}
delay(tempo/10);
}

delay(750);
if (checkButton() == CHOICE_A)
{
lcd.print("Ur not dumb");
}
else
{
lcd.print("Ur trash m8!!!");
}
delay(2000);
lcd.clear();
}
}

byte checkButton (void) { //what to do if the function check button is called


if (digitalRead(answerAPin) == 0) return(CHOICE_A); //if button A is pressed, return choice A
else if (digitalRead(answerBPin) == 0) return(CHOICE_B); //if button B is pressed, return
choice B
else if (digitalRead(answerCPin) == 0) return(CHOICE_C); //if button C is pressed, return
choice C
else if (digitalRead(answerDPin) == 0) return(CHOICE_D); //if button D is pressed, return
choice D

return(CHOICE_NONE); //if nothing is pressed return choice none


}
int frequency(char note) //set up function frequency
{
int i;
const int numNotes =17; //number of noted defined
char names[] = { 'L', 'c', 'd', 'Z', 'e', 'f', 'g', 'X', 'a', 'Y', 'b', 'C', 'D', 'W', 'E', 'F', 'G', 'A', 'B', 'C', 'P',
'O' }; //note names
int frequencies[] = {196, 262, 294, 311, 330, 349, 392, 415, 440, 466, 495, 523, 587, 622, 659,
698, 783, 880, 988, 1046, 1175, 1318}; //note frequencies
for (i = 0; i < numNotes; i++)
{
if (names[i] == note)
{
return(frequencies[i]);
}
}
return(0);
}

You might also like