This game was the semester project for my second year course Microprocessors. This project required students to create the wire touch game known as the Challenge of Mekon. This was to be designed using the Arduino, ATmega328P microcontroller and assembly code. my submission for the project uses interrupts for buttons, timer and touching the wire, which activates the red button and increments the score by two. Furthermore, the Binary to Decimal Converter (BDC) chip was used for the 7-segment displays. Other features include the frequency of the speaker sound constantly increasing as the score increases, an orange light goes on when the score goes over ten and a delay of 0.5s is being used to avoid unintended wire touches due to detection being too sensitive (know as debouncing).
Here are some of the block diagrams I used in the report for this project:
Below is the circuit diagram for the project I made for my report. I did this after I finally figured out how to wire up everything correctly, meaning it was not a guide for me, but more a guide for future reference or if other people interested in microcontrollers want to create a similar project.
Challenges Experienced and Overcome
- Learning how the BDC worked was fairly easy, but wiring up a 1K resistor for every LED on the two 7-segment displays took a lot of fiddly wiring. I solved this by taking pictures of the correct wiring I had done in case I had to break everything apart and re-wire it in the future.
- Learning about the correct interrupts, IVT- We had done many labs before this project, but finally I had to apply what I had learned in this project. I had to work with changing frequencies, the wires touching and multiple interrupts occuring at once to name a few. This learning was sped up by using the official Data Sheet for the Atmega 328p chip (use this religiously) and constant communication with classmates doing the same project.
- Making the pitch increase – This invloved setting the OCR2B register to 150 and decrementing it by one every time the player touched the wire. The calcualtion of 150 was the result of the equation focnxPWN = (fclk_I/O)/(n*256) = (fclk_I/O)/(prescalar*desiredFreq) = (fclk_I/O)/(256*desiredFreq) found on the Datasheet.
- Making the casing of the game – I was dreading this part and I though it would be low point of the project. However, one of my friends had thick wire, wood and a router (a hand tool or power tool that one uses to hollow out an area in wood). This allowed me to to create, along with blue spray paint, a farily strong and impressive stand and housing for my project.
- Debouncing – For those unfamiliar, debouncing is the removal of unwanted false triggers in the input of a circuit. This was done using a 0,5s register delay (as opposed to a timer delay) when the player touched the wire in the game. Debouncing was also done physically by sanding down the game wire with sandpaper, as wire bought from a store often has a thin plastic coating on it, to increase longevity.
- Score in the game – This was by far the most complicated aspect of the coding part of the game. Some features include:
- Ensuring the score stay correct when both the tens and ones displays change
- Displaying the orange LED when going over a multiple of ten, and then turning it off again
- Capping the game score at 99 to avoid unwanted symbols in the two displays (see Fig. 6 below)
7. TinkerCad – The clock was ticking for writing the report as my friends and I were all so focused on making the actual project. After first starting in MultiSim, and then trying LucidChart, I was then recommended using TinkerCad by our Engineering group chat. This free online application proved very quick and easy to use and I would highly recommend it (see Fig. 4).
Tips for future projects
- Indent your code from the labels above them – this will make the code much easier to read (see Fig. 5)
- Use “;_____________” to seperate code blocks (see Fig. 5). Note that “;” indicates a comment in assembly
- Define register names using .DEF, this makes it much easier to understand what the code is doing
- Work together with classmates, it is much less mentally taxing if a bunch of you are struggling with understanding certain concepts and applications. You don’t have to an intellectual hero for everything. Ask for help!
- Have a friend with a router and spray paint if you want to make your project look super!
This project was a hard, yet very enjoyable project. I learned a lot about Assembly, the Arduino Uno and how to make real projects come to life. For the future, I would want to start the project earlier than I did, but it was a busy time of the year. I hope you have learned something from reading this and inspired you to make your own Wire Touch Game or similar Arduino project. Good luck and I’ll see you in the next post!