It’s Eurovision time!

Is anyone looking forward to Eurovision tonight? If so, check out Sparki’s predictions for the event:

#include // include the sparki library
void setup() {
}
void loop() {
sparki.clearLCD();
sparki.drawString(10, 3, "Tonight is");
sparki.drawString(10, 5, "Eurovision");
sparki.updateLCD();
delay(3000);
sparki.clearLCD();
sparki.drawString(10, 3, "Shake me for my");
sparki.drawString(10, 5, "predictions");
sparki.updateLCD();
delay(5000);
for (int i = 0; i < 5; i++) { float x = sparki.accelX(); float y = sparki.accelY(); float z = sparki.accelZ(); if ((y > 2) || (y <= -2))
{
randomSeed(analogRead(1));
int response1 = random(1, 4);
if (response1 == 1)
{
sparki.beep(440, 100);
delay(500);
sparki.beep(440, 100);
sparki.RGB(100, 0, 0);
sparki.clearLCD();
sparki.drawString(10, 3, "Australia will do");
sparki.drawString(10, 5, "well!");
sparki.updateLCD();
delay(2000);
}
else if (response1 == 2)
{
sparki.beep(240, 100);
delay(500);
sparki.beep(240, 100);
sparki.RGB(0, 100, 0);
sparki.clearLCD();
sparki.drawString(10, 3, "The UK will score");
sparki.drawString(10, 5, "0");
sparki.updateLCD();
delay(2000);
}
else if (response1 == 3)
{
sparki.beep(640, 100);
delay(500);
sparki.beep(640, 100);
sparki.RGB(0, 0, 100);
sparki.clearLCD();
sparki.drawString(10, 3, "Sweden will be");
sparki.drawString(10, 5, "popular");
sparki.updateLCD();
delay(2000);
}
else
{
sparki.beep(640, 100);
delay(500);
sparki.beep(640, 100);
sparki.RGB(0, 0, 100);
sparki.clearLCD();
sparki.drawString(10, 3, "Graham Norton will");
sparki.drawString(10, 5, "be funny!");
sparki.updateLCD();
delay(2000);
}
}
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s