Pig Face

Pig Race
Playing the
CS 115:

Behind the Scenes

| Handy Board 1 | Handy Board 2 |

We will now reveal the secrets to how the Pig Race is operated!

There are two handy boards that controls the entire game:

Handy Board 1

  • Plays the theme song when game begins.
    • Done with the note generator function of the Handy Board. It is programmed with the concurrency command, forever, so that the song will continuously play throughout the game.
  • Moves the corresponding pig along the track when a player makes a goal.
    • A LED shines on a light sensor inside the goal, and when a ball crosses the light, the light sensor triggers the motor on the corresponding pig's track to move forward a certain distance.
  • When one of the pigs reaches the finish line, everything halts. Then, a congratulatory song plays, while the crowd cheers and a decorative banner unravels.
    • A LED shines on a light sensor across the finish line, and when a pig crosses the light, the light sensor triggers the whole application to halt. Then, it turns on the motor for the cheering crowd. Next, the motor that unravels the decorative banner is turned on. When the banner is unraveled, the congratulatory song stops.
  • After the congratulatory celebration, everything resets automatically: the pigs one by one move back to the starting line, and the banner rolls back up.
    • After the banner unravels, the motors on the tracks of the pigs are programmed to move backwards until the pigs reach the starting line, where reflecting sensors detect the color of the pigs, and triggers the motors to stop.
    • After the pigs are back at the starting position, the motor on the decorative banner turns on the reverse direction, rolling the banner back up to its original state.

* Click to view the code for Handy Board 1

Handy Board 2

  • A goal keeper that is in front of each goal moves side to side, making it more difficult for the player to roll the ball into the goal.
    • There is a reflecting sensor on either side of the goal box, which triggers the motor on the geared chain that is connected to the goal keeper to turn the opposite direction.
  • The goal keepers stop moving once a pig reaches the finish line.
    • Similar to how handy board 1 stops the pigs, when a pig reaches the finish line, it blocks a light sensor from a LED light that is on the other side, which triggers the motors on the goal keepers to stop.
  • After the congratulatory celebration, a treasure chest opens, revealing the prizes for the players. The chest waits for the players to reach in and grab the prizes, then it closes. (You better be quick though! or else the chest will close on you before you claim your prize!!!)
    • After the goal keepers halt, the program waits for a set number of seconds (waiting for the handy board 1 to finish congratulating and resetting) before it triggers the motor on the treasure chest door to activate. Then, the program waits again for the players to grab the prize, when it finally closes by reversing the motor on the treasure chest door.

* Click to view the code for Handy Board 2

Gowun Kim '06, Ji Lim '06
Robotic Design W'04