Tower of Hanoi

Overview

For our lab 4 project, we implemented the commonly known puzzle or game "Tower of Hanoi" on a Mbed using a uLCD-144-G2, a Sparkfun 5-way Tactile Joystick, a speaker with a class D audio amp, and a SD card reader. The program begins with an intro screen and an intro wave file. After, a short tutorial tells the basics of the game and the controls. In our implementation, there are 2 cursors: one selects the source column and the other selects the destination column. The source column cursor is the red circle that appears on the bottom of the screen and the destination column cursor is the yellow triangle towards the top of the screen. The object of the game is to move all 4 units to another column while following these conditions:

  • Only 1 unit can be moved at a time.
  • Large units cannot be placed on top of smaller units.

A move count is shown in the upper left corner. The game finishes once all 4 units are placed in a separate column (either column 2 or 3 since they are initially at 1). After, the program loops and the game can be played again. For the purpose of the demo, we implemented only 4 units due to the large amount of moves that it takes to complete the game with 5 or more units.

/media/uploads/molorvida3/tower.jpg

Components

Wiring

mbedCableuLCD
p28TXRX
p27RXTX
p30RESRESET
VU+5V+5V
GNDGNDGND
mbedSD CARD READER
p5DI
p6DO
p7SCK
p8CS
GNDGND
VoutVCC
mbedAmpSpeaker
p18In +
GNDGND, In -, PWR -
3.3V Vout (or VU)PWR +
Out ++
Out --
mbedJoystick
p16Up
p15Center
p14Left
p13Down
p12Right
GND-

Program

Import programTowerofHanoi

ECE 4180 - Lab 4 Tower of Hanoi


Please log in to post comments.