Think back to when you were a child...to the days of when you had the ability to make nostalgic memories. This project is inspired directly from one of my favorite memories: playing Keep Talking and Nobody Explodes with my friends. In this game, the goal is to defuse a bomb by completing a series of puzzles under a time crunch and strike policy. One of these modules involved watching a blinking light, getting a word from it in Morse Code, then submitting the corresponding combination into the bomb for that word. I remember struggling with my friends over the puzzle, as none of us had any sort of proficiency in reading Morse. This project of mine is inspired by this puzzle. It is a way to relive nostalgia, as well as learn a little bit of Morse Code.
HardwareFor a high-level view of how to assemble the hardware components, refer to the below hardware block diagram and power block diagram. For power, I used P2_21 as ground and P2_23 as power, with both connected to the buses on each side of the solderless breadboard.
Here is the pin chart for the Pocket Beagle:
Now, an instruction on wiring each component individually:
LEDs
For the green LED, connect the anode (orange wire) to P2_6 and the cathode (yellow wire) to ground. For the red LED, wire the same except the anode goes to P2_4.
Buzzer
Connect the positive end (white wire) to P2_1 and the negative end to ground.
7-SegmentDisplay
Connect the positive pin to power (left most wire) and the negative pin to ground (second from the left). Then, run power to the SCL and SDA (both brown wires), ensuring that there is at least a 1K Ohm resistor in between power and the display. Finally, connect SCL to P2_9 and SDA to P2_11.
SPIScreen
This component was by far the hardest one to wire, as it is super involved. Start by connecting the VCC to power and GND to ground. Connect CS to P1_6 (orange wire). Connect RESET to P1_2 (brown wire). Connect DC to P1_4 (red wire). Connect MOSI to P1_12 (blue wire). Connect MISO to P1_10 (green wire). Connect T_CLK to P1_8 (yellow wire).
Joystick
Before wiring, on a more personal note, I love messing with the joystick, its so satisfying. Okay, so connect GND to P2_15 (blue wire). Connect 5V to P2_13 (purple wire). Connect VRX to P1_19 (white wire). Connect VRY to P1_21 (white wire). Connect SW to P2_19 (green wire).
You should have everything wired correctly now! Using the sample code in my GitHub labelled python, navigate to the files and you can test the wiring by running the codes that are labelled by the component name. Credit for these codes goes to Erik Welsh. On a sidenote, you will not find a test code for the joystick, as I had to code that myself.
The hardware side of this project is done, at least for now. I cannot imagine adding anymore components at the moment, and these wirings work. Maybe in the future I will amend the game and it will require more components
SoftwareCode
Starting this project was very daunting. I have little experience coding in general, and my knowledge of python extends as far as knowing syntax. I had only ever done functional programming and had never touched object-oriented programming. From the start, I knew that the time I spent coding would be the same amount of time that I spent reading documentation, watching coding videos, and learning. However, as I went through this project, I found that I became faster at coding, understanding the logic of my code, and I my confidence grew.
I based a lot of the code of my components on the libraries provided to us by our professor, Erik Welsh, for our class (ENGI 301). Specifically, I used the libraries he provided for buttons, 7-segment displays, SPI screens, LEDs, and buzzers. To locate this code, as well as my code for this project, click here for my GitHub!
Below is my software flowchart, which shows my thinking on how this project will work. Let me preface this section by saying that code does not currently work as it is not complete. However, I will cover what does work, what I need to code, and how I will debug and improve this over the summer.
Getting into the code now, my goals for the code were for everything to work in tandem using threading. The SPI screen drives most of the interaction with the user with the joystick allowing user communication. The buzzer communicates with the user the Morse Code as well as sounds for correct and incorrect answers. The LEDs also indicate correctness of answers. Finally, the display shows the countdown timer for the game session. Now for a little more low-level description.
Operation
I would provide a video of the device working, but unfortunately it does not work as desired. Here is how I imagine it will work and then I will outline my plan to implement all the code that I want and update this page with a video of the device. The overall goal of the game is to hear the Morse Code from the buzzer, then use the joystick to input the word into the device.
1) Turn on the device by applying power. The device will initiate the game on power up.
2) SPI screen powers on and will display the rules of the game while the display shows blank
3) Use the joystick to select a level of difficulty
4) Display shows the time for the level, SPI screen shows blank lines for the passcode
5) User presses the joystick, game starts, buzzer starts playing the word, timer starts counting down
6) User inputs the word when ready and then if correct, timer and buzzer stop and green LED comes on; if wrong, buzzer plays a negative sound, red LED comes on
7) User can choose to play again; if not, device turns off
Future PlansI would like first of all to make this device work. I am proud of this idea, and think with a little more time, I will be able to complete this. I need to implement the SPI/Joystick interactions first of all. I then need to do threading for the LEDs, the buzzer, the screen, and the display. Finally, I will definitely need to debug. In the future, I want to update the words that the device will choose from and make them more similar so the game is harder. I also think implementing a strike system would be cool, in that you can set the number of wrong guesses the user can make.
ConclusionOverall, I'm proud of this project and think I made good progress. There is work to be done, but that work is doable and I will finish this project. I want to thank Professor Erik Welsh for helping me with this project, I definitely would not have been able to do any of this without him.
Comments