Quasimodo Game

About: Interaction design student at HKU

How to get up early in the morning? We tried to solve this problem by NOT giving a reward when you get up, but making a challenge of it. In this little challenge, you are Quasimodo. You hear a list of sounds and you need to copy the sounds by pulling the right ropes in the right order. If you pull the wrong rope, the red LED will lighten up and you know that you were wrong. Pull again and play again. When you're right, the green LED will lighten up and you're allowed to get out of bed.

Step 1: Step 1: Set Up the Circuit

We need at least 3 buttons (as in this example), 2 LED's (1 red, 1 green) and 1 piezo buzzer.

Set the buttons in pins 9, 10 and 11 (no resistor needed, pullup restitor of the Arduino is used by code).

Set the LED's in pins 2 (red) and 3 (green) both with a 220ohm resistor.

Set the buzzer in pin A0.

Step 2: Step 2: Code Game

Include libraries:

TrueRandom (because the normal random() function isn't really random)

https://github.com/sirleech/TrueRandom

Button (to make button click events easier to handle)

https://github.com/madleech/Button

boolean gameStarted = false;
int sounds[3] = {};
int pressedSounds[3] = {};
int amountPressed = 0;

// led pins
int led1 = 2;
int led2 = 3;

// buzzer pin
int buzzer = A0;

// button values
Button button1(9); // Connect your button between pin 2 and GND
Button button2(10); // Connect your button between pin 3 and GND
Button button3(11); // Connect your button between pin 4 and GND

void setup() {

  Serial.begin(9600);

  // put your setup code here, to run once:
  // pinmodes 3 buttons, 2 LED's & 1/2 buzzers
  button1.begin();
  button2.begin();
  button3.begin();


  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

  pinMode(buzzer, OUTPUT);

}

void loop() {
  if (button1.released() || button2.released() || button3.released()) {
    gameStarted = true;
  }

  if (gameStarted) {
    game();
  }
}

void game() {
  sounds[0] = TrueRandom.random(1, 3);
  sounds[1] = TrueRandom.random(1, 3);
  sounds[2] = TrueRandom.random(1, 3);

  Serial.println("game started");
  Serial.println(sounds[0]);
  Serial.println(sounds[1]);
  Serial.println(sounds[2]);

  // play sound to imitate
  playSound(sounds[0]);
  playSound(sounds[1]);
  playSound(sounds[2]);

  Serial.println("sounds played");

  while (gameStarted) {

    if (amountPressed < 3) {

      if (button1.released()) {
        pressedSounds[amountPressed] = 1;
        playSound(1);  

        Serial.println("button 1 pressed");
        Serial.println(pressedSounds[amountPressed]);

        if (pressedSounds[amountPressed] != sounds[amountPressed]) {
          wrongAnswer();
        } else {
          amountPressed++; 
          Serial.println(amountPressed);
        }

      } else if (button2.released()) {
        pressedSounds[amountPressed] = 2;
        playSound(2);  

        Serial.println("button 2 pressed");
        Serial.println(pressedSounds[amountPressed]);

        if (pressedSounds[amountPressed] != sounds[amountPressed]) {
          wrongAnswer();
        } else {
          amountPressed++; 
          Serial.println(amountPressed);
        }

      } else if (button3.released()) {
	pressedSounds[amountPressed] = 3;
        playSound(3);
        Serial.println("button 3 pressed");
        Serial.println(pressedSounds[amountPressed]);

        if (pressedSounds[amountPressed] != sounds[amountPressed]) {
          wrongAnswer();
        } else {
          amountPressed++; 
          Serial.println(amountPressed);
        }
      }
    } else {
      goodAnswer();
    }
  }
}

void playSound(int value) {

  int freq = 500;  

  tone(buzzer, value * freq);
  delay(1200);
  noTone(buzzer);
  delay(400);
}

void wrongAnswer() {
  digitalWrite(led1, HIGH);
  delay(3000);
  digitalWrite(led1, LOW);
  amountPressed = 0;
  gameStarted = false;
}

void goodAnswer() {
  digitalWrite(led2, HIGH);
  delay(3000);
  digitalWrite(led2, LOW);

  amountPressed = 0;
  gameStarted = false;
}

Step 3: Step 3: Build Hardware

The hardware consists of a plank, ropes and wires to solder.

1. cut a piece of the plank for each button (to press the button)

2. make holes in to the big plank and the pieces to get the ropes through the planks.

3. get the 3 pieces of rope and pull it through the pieces of wood and knit it at the bottom.

4. Solder the buttons and the LED's to the wires and connect the wires to the Arduino and the ground (make a special board for all the ground wires to connect them all with one ground pin on the Arduino)

5. Attach the buttons under each piece (with glue or tape) and vasten the wires to the plank.

Step 4: Step 4: Finish

Fasten the hardware to the roof above your bed. Get a long-lasting power supply for your Arduino and connect it. Waking up will be more fun, but harder all the upcoming early mornings :)

Share

    Recommendations

    • Organization Contest

      Organization Contest
    • Build a Tool Contest

      Build a Tool Contest
    • Faux-Real Contest

      Faux-Real Contest

    2 Discussions

    0
    None
    luuksiewersrandofo

    Reply 16 days ago

    We did it for a seminar at the HKU in Utrecht. De exercise was to make a 'happy hack' by solving a common frustration in a fun way :)