Assignment 1: Ball Drop Game

Assignment 1: Ball Drop Game

The Idea

The project consists of developing a controller to play Ball Drop Game,  a TCP sockets multiplayer game developed by Tom Igoe.  The main idea was to use an Arduino with multiple sensors to control a player through TCP sockets in a game running on someone’s computer. We learned about the various layers of protocol we need to build a network in order to build this communication. The physical layer and the datalink layer were defined by our hardware and their addresses, in this case the Arduino and the laptop connected to a same WiFi network.

The network layer and the IP adresses were managed by the local network, while the transport layer consisted of a TCP socket between each player(client) and the computer(server). We used sessions to open and close the connection to the server with a physical interface, and finally we sent characters through the connection as commands to the player on-screen. The game itself consists of a screen where each player is a bar, and the idea is to collide with a ball that falls from the top of the screen as many times as possible. 

 

The Video

Bill of Materials

– 1 Arduino Nano IoT
– 5 momentary buttons (like these)
– 1 Breadboard/ PCB (like these)
– 2 LEDs (like these)
– 1 meter of 22awg wire (like this)
– 1 sheet of 12in x 12in Birch plywood

The Process

The system consists of an Arduino Nano 33 IoT connected to five buttons and two LEDs. One of the LEDs indicates power while the other LED indicates connection. The array of four buttons displayed in a rectangular position are the controls for the game, UP, DOWN, RIGHT and LEFT.  The remaining button is used to connect and disconnect from the server.  Below you can see how the player would move in the game.

Ball game by Tom Igoe.
Ball game by Tom Igoe.

We had already connected in class through our computer terminal, and thanks to Tom Igoe’s example the process to implement the same protocol through the Arduino was straightforward. I also have to thank Tirta and Sam Krystal for helping me out with implementing the pull-up logic with the Arduino code Tom had shared. As you can see below, the circuit on the left used a setup where the resistors were connected to ground. On the right, there is no resistor going into ground, since the Arduino’s internal resistors “pull-up” the excess voltage.

First attempt.
First attempt.
Pull-up circuit.

After learning how to use the laser cutter I decided to iterate through cardboard before settling on a wooden enclosure using the plywood. The process wasn’t as fluid as I thought, since the laser cutter did not work perfectly and the seams would not fit sometimes. Anyways, I changed the layout several times until I was satisfied.

Cardboard iterations.
Cardboard iterations.
First prototype.
Several iterations later.

I then proceeded to solder the buttons and the wiring in order to have a button pad. The PCB I had was kind of frustrating to work with because it’s hole arrangement did not permit a symmetric disposition of every element.

Soldering buttons
Soldering buttons
Soldered buttons.
Soldered buttons.

Finally, I decided on the design below. I decided to go for a small breadboard because of its size and weight. I also added another LED, so one of them would indicate the device is on and the other indicates connection.

Enclosure and circuit board.
Enclosure and circuit board.
Drying prototype.
Drying prototype.

Circuit Schematic

Circuit Diagram.
Circuit Diagram.

The Code

Thanks for reading!