Design and development of a game using a Microchip PIC micro-controller. Detailed analysis of the development process to create the circuit and assembly code.
First part in the series of design and programming of a Microchip PIC game. Demonstrating and describing the end product in detail, in order that the following parts in the series have a reference to show what effects are being developed.
VIDEO
PIC Game Programming PART 2: HARDWARE
A description of the simple circuit required to make this project. Describing the circuit operation and design for low power consumption, due to the project being powered by a single CR2032 coin cell battery.
VIDEO
PIC Game Programming PART 3: PCB
The assembly of a PCB for the project. Discussing the placement of components on both sides of the PCB to reduce the overall footprint and improve usability. And the use of a printed out silkscreen layer to aid the assembly of home made printed circuit boards.
VIDEO
PIC Game Programming PART 4: SOFTWARE DESIGN
Presentation covering the software design, approach and concepts used. Covering software and hardware initialization, finite state machines, settings, game play, low power mode and restarting game play.
VIDEO
PIC Game Programming PART 5: ANIMATING LEDs
Starting the development by laying out a template for a PIC assembly program and writing the functions to control the LEDs in the circuit. Create a test harness to prove the functions are working and program the compiled code onto a PIC device to see the effect in circuit.
VIDEO
PIC Game Programming PART 6: PLAYING SOUND
In this part the functions for playing sound are added. An interrupt handling routine is required so the micro-controller timers can be used to generate audible frequencies. The issues around using interrupts are described and the test harness is updated to play a tune while the LEDs animate with the code added from the previous part.
VIDEO
PIC Game Programming PART 7: READING SWITCHES
The timer 0 interrupt is handled, this moves much of the previous test harness code into their correct locations and adds the call to the read switch state function. The test harness is updated to check for switch presses and play the win tune when a switch is pressed. Additional switch functions required for the game play are added and the pause function has been removed from the test harness and written for multi-threading purposes.
VIDEO
PIC Game Programming PART 8: RANDOM NUMBERS
Generating random numbers, so each time the game played it is a unique experience for the user. Explaining why not all RAM in cleared at start up, the process of adding random values to a cache of random numbers and overwriting them on a regular basis. Having a simple call to get a random number when one is required. The test harness is replaced to constantly display flashing random LEDs.
VIDEO
PIC Game Programming PART 9: LOW POWER SLEEP
Placing the device in to low power mode after no activity for a period of time. This allows the device to switch itself off and not require a power switch. Pressing any key will turn the device back on again. Also covered is the initial finite state machine, which will be used to run the application.
VIDEO
PIC Game Programming PART 10: USER SETTINGS
Handling user key press actions for selecting game level, toggling sound on and off and starting a game. Adding the required function to the applications finite state algorithm. Using the process of check for required key and perform required action, and finally clear processed key presses ready for next time.
VIDEO
PIC Game Programming PART 11: GAME PLAY
Final part in series. Playing a game, adding a random number to the sequence of random numbers, playing the sequence on the LEDs, with sound if enabled, and the user playing back the sequence played by the micro-controller. Repeat the process until the player times out, gets it wrong, or wins the game.
VIDEO
How To Make A Solar Powered Simon PIC Game
As part of my series on programming this project, a quick aside, showing the game being played solely from solar power. Sound has to be turned off with a solar panel this small, but the game can still be played.
HARDWARE
This project is ideal for learning to program PIC micro-controllers as the circuit is very simple and easy to put together. The source code covers many concepts such as:
Logic operators in both pre and post compiled.
Finite state machines.
Generating random values.
Handling processor interrupts.
Using timers.
Bi-directional ports.
Reading inputs.
Setting outputs.
Generating audible sounds.
Designing low power circuits and software.
PIC Game Hardware PCB
MAKING
The circuit can be assembled simply on strip-board.
The videos in the series listed above, go into detail describing how the software works and provide comparable examples which can be programmed onto a PIC device and tried. The final video shows the source code in completion, this source code is Open Source and can be programmed onto a PIC device and used in the circuit shown on this page. A full copy of the Open Source license must be kept with the source code at all times, with a credit to the original author Jason Birch.