Inspiration

We wanted to do a fun game using a light up matrix that would teach us skills about incoming analog data, as well as enhance our skills using binary data. We chose the arduino because we have recently begun learning about coding for hardware in school, and we thought it would be interesting to put our knowledge to the test.

What it does

There are two different games included in the program.

The first game is standard pong. You and an opponent attempt to hit an incoming ball with a bar that moves along that players' side. The first to miss the ball loses. The player that won is then displayed on the matrix.

The second game is light-dodger. Essentially, a player is a ball of light that can move in any direction on the matrix. A second ball bounces around the matrix. As the game goes on, the second ball increases in size and/or speed. If the player is hit by the ball, they lose.

There is a button on the breadboard that switches between games when pressed. When first uploaded, it must be pressed to begin a game. If the user desires to change games they must press the button again.

How we built it

Two joysticks and a matrix are wired to a single arduino. We began by coding the pong game. Next we coded the light-dodger game. To get them to work at the same time, we created a separate folder and modified the first two programs such that specific functions could be called in the main program. When the button is first hit, the pong game will be called. The game either plays to completion or the users may press the button mid-game to switch to the second game.

Challenges we ran into

The matrix works by writing a specific binary number that acts as a row. The hardest part of pong was getting the ball to move column-wise in a manner that made logistical sense. A major error that we faced was a glitch where, when a board was reached, it would move over two columns rather than one. Eventually, we noticed that we were shifting the ball's binary before we assessed if it had hit the board. The direction it shifted was dependent on whether it had previously been going left or right. Code was implemented to fix this.

The primary issue with light-dodger also had to do with writing rows as binary. When the player and the ball of light were in the same row but not the same space, the player would be overwritten by the light, and only the ball would be seen. This was combated with a few if statements that compared the binary value of light/player and the row they are on.

Accomplishments that we're proud of

In pong, having it properly recognize whether or not a player lost. In light-dodger, getting a pattern that could not be easily predicted by the player. Getting the two programs to compile run together.

Built With

Share this project:

Updates