Microcontroller Project | Memo Game Sound


This example will show you how to build a PIC based simple memorization game system. With only a PIC16F84A and a few cheap components, you will train your brain first to understand a few basics about PICs, second to play to a not that easy memory game !
PIC Sleep Mode and Wake-Up from PORTB Change are the keys of the software.

Game rules
You will have to memorize a melody, made of up to 62 steps.
A step is one of the four tones available in the game system.
In order to help you, each tone is associated to a color LED (yellow, green, orange, red) which lights each time the tone is played.
The game system plays the melody, then you have to repeat it correctly by pressing the button of the tone's LED. At the beginning, the melody has only one step.
If you fail, an error melody is played, the melody is played again and you can try again to repeat it.
If you succeed, a new tone is added to the melody.
The longest melody is 62 step long, will you be able to learn it by heart ?
If you get bored with one melody, press the RB4 and RB5 buttons at the same time, the game system will create a new melody.
If you want to modify the melody rythme, press the RB6 and RB7 buttons at the same time, and select a new rythme by pressing a key when the LED is on :..................................



RA0 : very fast
RA1 : fast
RA2 : slow
RA3 : very slow (default)
Circuit Schematic
The game is battery operated, and the circuit is powered with a LP2950CZ-5.0 regulator with some decoupling capacitors. There is no main switch, because the circuit is in sleep mode when nothing happens. A standard 9V battery should work for weeks.
Four switches are connected to the PORTB high nibble to allow wake-up on PORT change of the PIC when the player press a button. There is no pull-up resistors, because internal weak pull-up of the PIC is used.
The RB0 pin of the PIC drives directly a little piezzo speaker.
The PORTA low nibble drives fours LEDs, through current limitation resistors.
A cheap 8Mhz crystal is used to clock the PIC, you could add the two 15pf capacitors from crystal to ground to follow Microchip recommendation, but the PIC works very well without, just do it if you have a lazy PIC that does not start oscillator.
PIC C Source Code
This project is made for a PIC16F84A MCU, but could be changed to any other PIC MCU with only a very few adjustments.
As this project fits within the 2k demo limit of the mikroC compiler, you can use it for free, download it from.

PIC16F84A Memsound circuit schematic














EEPROM Definition :
This project uses the internal PIC EEPROM, you have to add this EEPROM definition to your project :

0x00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
0x10 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
0x20 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
0x30 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 04

You can download the .HEX file for PIC16F84A 8 Mhz crystal here :
DOWNLOAD.Hex
 
Prototype
Here is the picture of the prototype I built with VeroBoard :

1 comments:

Anonymous said...

Your blog seems to be having some compatibilty problems in
my safari browser. The wording appears to be running off the page pretty bad.

If you want you can contact me at: pat.laporte@arcor.de and I'll shoot you over a screenshot of the problem.

Feel free to surf to my site ... investment property rates interest

Post a Comment

 

Free Download Engineering Books - IEEE Books | Copyright 2009-2013 All right reserved | Design by BMW Automobiles | Created by Umair Sheikh