For this week’s project, I decided to upgrade my previous Blobby game (where the user’s pink blob tries to eat the mean blobs) by adding various features to it. I really wanted to practice both a) having Processing receive information from the Arduino, and b) having the Arduino receive information from Processing. So, I added two features to the game of each type of interaction. For the first type of interaction, I have 1) a potentiometer and 2) a button, and for the second type, I have 1) a Piezo buzzer, and 2) a RGB led. How these interactions work is the following:
- The user can use the potentiometer on the Arduino to speed up or slow down the movement of the mean blobs; this increases or decreases the difficulty of the game.
- The user can press the button to change the background color of the game. The color changes randomly each time the button is pressed. This feature is both fun/somewhat pretty, as well as another way for the user to increase the difficulty of the game: certain background colors make it harder to see the mean blobs and to avoid them.
- In regards to the Piezo buzzer, the following happens: when the user (the pink blob) eats a smaller mean blob, a happy two-note sound plays from the buzzer. Additionally, when the user wins, a happy five-note tune plays; when the user loses, an low, “angry” sound plays for a few seconds. These sounds add a really interactive, fun element to the game.
- The RGB led light serves as a signal of winning/losing. When the user wins, a pink color (like the user’s blob) turns on for a few seconds after the happy five-note wining tune plays. Similarly, when the user loses, a green color (like the mean blobs) turns on for several seconds following the losing buzzer sound. The lights add an extra element to the game because they reinforce the results of the game, and when they turn off after a few seconds the user knows they can start the game over again. (I originally wanted these lights to turn on at the same time as the end buzzing sounds, but I discovered that the buzzer interferes with the LED and alters the color of it. For this reason, I have the LED only turn on after the buzzer sounds are over.)
While it was nice to get to work with previous code, I find it very difficult to wrap my head around the communication between Processing and Arduino. It was for this reason that I wanted to practice implementing so many different types of communications between the two (and because I needed to remind myself again how to use those Arduino sensors/etc.). Overall, the project was a great learning experience.
Here is a picture of the bus board and circuit board:
It was difficult to get a good video of all the different features; below I will provide only two that can give an idea about the updated game.
(1) This first video shows a winning game. As you can here, every time the user eats a mean blob, there is a positive sound. Additionally, when the user wins in the end, there is a happy tune. (Additionally, even though you cannot see my hand on the bus board, you will notice that the blobs increase/decrease speed — that is me moving the potentiometer. Similarly, when the background color changes it is me pressing a button.) Lastly, I forgot to include it in the video, but the Led lights up pink at the end upon winning.
(2) The second video is just a few seconds and shows the ending of a losing game: the losing screen comes up, the angry buzzer sounds, and the Led lights up green.
The code for this project can be found here.