This project shows how to create an MB Electronics Simon game clone using an 8-pin PIC12F683 microcontroller. The game includes a full emulation of the original Simon 'game 1' and the ability to select from 4 skill levels which control the number of colours you must repeat in a sequence in order to win the game.

The project was created for Sparkfun's microcontroller competition 2011 and aims to demonstrate an number of useful design techniques which can be used when working with low-pin count microcontrollers. The code is written entirely in C and fits neatly into the 2K of available program flash on the chip. The PCB is only 1.5 inches square and uses both SMD and through-hole components, however it is perfectly possible to recreate the project using larger components on a breadboard or a small piece of strip-board.

The game is powered by a standard CR2032 3V lithium cell which is mounted on the underside of the game. The design uses the ultra low power standby feature of the microcontroller meaning that no power switch is required. Overall power consumption is kept to a minimum by using the internal oscillator of the PIC running at 4Mhz.

You can see a video of it in action over on youtube

Step 1: Parts List

The MicroSimon hardware consists of the following parts:

* 1 x PIC12F683 SOIC 8-pin microcontroller
* 5 x 10K resistors (1206 SMD)
* 1 x BC817 NPN Transistor
* 1 x 100nF capacitor (0805 SMD)
* 4 x 3mm LEDs
* 1 x CR2032 battery holder
* 5 x Tactile push-button switches
* 1 x QMX-05 speaker
* 1 x 6 pin 2.54" right angled header
<p>can you post a hex file for this? I am getting errors on your code and i'm still a newbie in coding or generating hex...</p>
Nice. I like this a lot and I have a few 12f683's sitting around. Nice code, too.<br><br>One totally useless tip:<br><br>randomNumber++;<br>if (randomNumber == 5) randomNumber = 1;<br><br>could be<br><br>randomNumber &amp;= 0b11;<br>randomNumber++;<br><br>to get rid of the branch, not that you have such a busy loop that you need to save instructions...
@Grazfather - You could actually do it in one line using the mod operator, something like:<br><br>randomNumber = (randomNumber + 1) % 5;<br><br>But there is always the trade-off between code readability and memory efficient coding. I always go the 'readable' route unless I really need to save some bytes.
Actually, you'd want <br>randomNumber = (randomNumber % 4) + 1; <br>The way you have it, it'll make a number between 0 and 4, but it looks like you're looking for a number between 1 and 4 in the original code. <br>Or you could do <br>randomNumber = (randomNumber &amp; 0b11) + 1; <br>With the same effect of being on one line...
However, you should not use a mod operator here, because depending on the compiler your mod operator could end up eating up a lot pf processing. On most processors, division (including modulo division) is about the very slowest single action you can have the processor take, and for a PIC, it might end up expanded into a fairly large subroutine call. (If you are paying a few hundred dollars for a proprietary compiler for embedded system development, then it might not matter, as the compiler will likely optimize it to the same thing Grazfather suggested)
I like the resistor ladder for the buttons a lot. <br>I'm definitely going to use that in a project I'm working on, but with one small change: the top resistor I'm planning on making a 4.7k vs. all 10k. The reason is, it staggers the values to be away from binary midpoints so I can just look at the top few bits of the ADC. It'd put the values at approximately 68%, 40% and 28%, rather than 50%, 33% and 25%. Having 33% and 25% in there means I'd need to look at more bits of the ADC, but with these values, I can easily get away with looking at only the upper 3, as long as the resistors are within some reasonable tolerances (i.e. not 20% resistors). I really don't like 50% and 25% being in there, because it could be that you have 1000000000b or 0111111111b for 50%, and similar for 25%, and I'd rather just say &quot;ignore the lower N bits, and if the upper bits match this value exactly, you have button press.&quot; :) <br>Anyway, just a thought. It really depends more about your code size vs. stock of resistors. Still can do the same thing with all 10k, just needs more bits and therefore more cases to handle.
Simon, I need desperate help with a similar project using a 16F84. Unfortunately my programming skills are absolutely awful. I have the 4 inputs on PORTA and the 4 LEDs on PORTB but I can't for the life of me figure out how to program SIMON into the chip. I know the commands but figuring it out is intensely frustrating.
hello i have made your project but the programming is a little <br>problem, cause i use winpic wat for code do i need to use for <br>that program, i dont program for a long time so i hope you can help my <br> <br>
You need to use MPLAB from Microchip to do the programming. You can download it (and the compiler) free from their website.
Here's the version of Colin Mitchell i have realised : http://www.youtube.com/watch?v=IzJERfsaF6E
I have used Colin Mitchel one's with a pic16f84A : http://www.talkingelectronics.com/te_interactive_index.html <br> <br>it is great! :) <br>congradulation Colin! <br>Keep the good work! <br>marC:)
2n3904 is okay?
It should be fine. I've never used one myself, so I can't be 100%. The application is a very basic one though, so pretty much any NPN would probably do the trick.
any other substitute for bc817? <br> <br>thank you! <br>marC:)
Any small signal NPN would do (like a BC337 for example).
2n3904 should work? <br> <br>do you have a bigger schematic please? i don't see much on this one <br> <br>thank you! <br>marC:)
Follow the link in my profile to my website; there you will find better pictures of the project.
is there any other pic that i can use i cant find that pic where i live
I would think that any similar PIC12F should do the trick. You will need to alter the fuse settings accordingly though.
what about the PIC12C508A the only difference i see is the memory this one is EEPROM and yours is flash
I can't say I've played with that many types of PIC12F to really give you good advice (I usually work with 18Fs). Microchip have an on-line product selection tool which you may find useful:<br><br>http://www.microchip.com/productselector/MCUProductSelector.html
i have another question you have your own pic programmer or you using pickit?<br>because pickit is expensive and i would like to make my own programmer if i can
thank you this is my first project with a pic im kinda confused because i dont know much about pics but ill try to do this thanks for this tutorial
Hello! <br><br>Really nice project! Congratulations!<br><br>I have one problem though. How can I assemble all these .c and .h files to an .asm file in order to load them to the PIC microcontroller? I tried microC for PIC and MPLab IDE but I couldn't managed it.<br><br>Thanks!
The source code is for MPLAB with the HiTech PICC18 compiler which you can download for free from Hi-Tech's website. The code will not work with microC or microchip C18 compilers without alteration.<br><br>Hope this helps!
I 'll try it later today..<br><br>Thanks!
Very well done!

About This Instructable




More by simoninns:RGB LED Love Heart MicroSimon 
Add instructable to: