I'm too much pro-gamer and am offended that people play video games just for fun.
I'm kidding, I actually have been wanting to do a hardware hack for quite some time, and watched Michael Reeves' videos where he makes useless and funny robots, so I wanted to do something like that myself.
What it does 💪🏓🚀
Pong-Booster helps you get better at Pong by raising the stakes for losing. Every 5 points you lose, a Ping Pong ball hits you right in the face to tell you to focus and train harder!
How I built it 🔨🎮🐍🤖
Pong-Booster has 3 parts, the first of which is the actual game. The game (Cata-Pong) is basically Pong built in Unity that has an AI for the other player and outputs the CPU score to a streaming asset text file.
The second part (the Loser-Master-6000) is built in Python. It is a short script that reads the text file outputted by the Pong game, and every 5 points you lose, it communicates to the Arduino Uno to release the catapult.
The last part is the Keep-Me-Awake-Inator: the actual catapult itself. It consists of a servo connected to an Arduino Uno that can release a rubber band to launch the Ping Pong ball.
Challenges I ran into 😬😬😬
My project was a great example of Murphy's Law; everything that could go wrong did go wrong.
All the Unity Problems
I had never used Unity that well before and had never created a playable game, so there were a lot of challenges. For example, I didn't know that when you build the game, the assets get compressed so I learned about Streaming Assets so that the Python script could read the file. Then, I realised Streaming Assets have a special case-sensitive designation that I did not follow. Further, I didn't know there was a special way to write the path of a Streaming Asset so I was originally getting very weird errors and bugs. Even creating the AI was a problem because the tutorial I was watching was for making a 2-player Pong game, which I had to severely modify to get Player 2 to be an AI and non-playable.
Python is usually my comfort zone but this time, the package names had me very confused. The package to communicate with the Arduino was 'serial' in all code, but the actual package name was 'pyserial.' But, because I had downloaded the serial and pyserial packages already, I had to uninstall both, reinstall only pyserial, and do some other small changes to get it to work. Luckily, StackOverflow exists.
The Arduino Board was surprisingly easy to code, but what was hard was setting up the connection from Python to the Board itself. I knew ports existed and the theory about that sort of thing, but I had never actually used ports before and communicated to them on such a deep level. This was hard, but the Arduino Forums were very helpful.
Uploading to GitHub
GitHub is very cool and I've used it for all of my hackathons, but when I wanted to upload my project (folders and all) to it, the folders would just disappear. I had to solve this problem by using git which I had never used before and was initially very consuming. I kept getting every error imaginable but I just calmed down and tried to re-do everything which made it finally work.
The Popsicle Stick Catapult
My original plan for this was to attach the servo to the side of the catapult and to attach a popsicle stick to the servo which would act as a stopper to the main catapult arm. However, my servo wasn't strong enough and there was too much tension in the catapulting rubber band. This made me change my design to put the servo on the back, instead and release a second rubber band to fire the servo. But then I realised I had run out of hot glue, a true nightmare, so I had to resort to masking tape, double-sided tape, and small dabs of hot glue only in the places that absolutely needed them.
Accomplishments that I'm proud of 🥇🏆🎉🥳
Finally completing a project in Unity
I've got at least 7 unfinished and disgustingly disorganised Unity projects just sitting on my hard drive, but this is the first one I actually finished. Sure, I completed a tutorial before, but this time, I actually changed a lot and implemented a lot of my own code.
Pulling Everything Together
On Saturday, I literally thought there was no way to put out this dumpster fire and turn it into something actually fun to play and funny to watch. However, I think I'm really proud of my project and happy I proved myself wrong.
What I learned 🧠🧠
Unity Functions, Writing to Text Files, etc.
Almost all of the code I used in this Unity project was something I learnt because I was really, really bad at it before. All the functions and a lot of C# Syntax (like try-catch) was new to me, and I realised that C# isn't as intimidating a language as I thought it to be. Even something like Streaming Assets that don't get compressed in the build is something really important that I learnt this weekend.
This is a similar story to the C# that I learnt because I've always found Arduino programming and C to be kind of difficult and painful, but this time, I really enjoyed it. I also think the way I communicated with the Arduino using Python is really fun and easy, which I think I might be using a lot more of.
What's next for Pong-Booster ⏭⏭
I love the Loser-Master-6000, but the Cata-Pong could use some improvements. While I am proud of finishing a C# and Unity project, I would ideally like to have a main menu, a reset button and some other basics in Cata-Pong. Also, the Keep-Me-Awake-Inator currently requires manual reload because I only had one motor, but if I could get more, I would like to make it automatically reload so that you can keep playing and not stop to reload (even though it takes barely a second).