Introduction

When I was younger we had an electronic toy which had four flashing lights and a speaker that output tones. The toy would output a random sequence of notes that you had to copy by pushing the lights (they were also buttons). This little project implements a similar copycat game on the LPC1114.

Wiring

The wiring diagram is shown below.

Code

Source code is available here

Operation

The video below shows the operation of the program. It begins with a little tune that I hope you recognize. The program then waits for you to hit any of the 4 LED buttons. It indicates that user input is required by flashing all lights quickly. Each round consists of the micro producing a sequence of tones and flashes. The user must copy the sequence after being prompted (two brief bursts of all lights). If the user make a mistake, the white and red LED's flash quickly. If the user completes all 8 rounds successfully then the 4 leds light up in rapid succession.
An element of randomness had to be added to the game. This is achieved using a Pseudo Random Binary Sequence (prbs) function. The function is called by the main program thread and also by a periodic timer interrupt (1kHz). The cycling of the prbs function by the interrupt service routine adds an element of uniqueness to each game as the player's response times will never be exactly the same.
Thanks to Sam and Oran for testing and demonstrating.


Back to LPC1114 home
Back to Baremetal ARM home