You are hereHome / Arduino Projects / Project Page: Networked Game Controller

Project Page: Networked Game Controller


Networked Game Controller

Project CaseThe networked game controller is MTT project #7.  The idea is that a pong-like game, where the ball moves vertically instead of horizontally, is played via a networked controller.  Author Tom Igoe did most of the heavy lifting on this one as both the server and client programs are provided.

My job was to build the “seesaw” controller, which is operated by the player’s feet.  I learned a lot on this project, including how to program client / server software in Processing and Arduino and that dollar store batteries don’t last very long.  Oh well, at least I was able to buy a decent project case for a buck.

Building the Controller

Found Leaf SpringIn the book the case sits on top of a piece of scrap wood with a pipe used as a fulcrum.  I didn’t have any scrap wood and did not know what I could use.  As I stood at the bus stop on my way home from work one day thinking about it I looked down and there was a piece of a broken leaf spring in the gutter.  This hunk of curved metal looked like the perfect material to use for my controller base.

Sanded Leaf SpringI put the spring in my bag and sanded it down with my Dremel  when I got home I.  Some red spray paint from the local hardware store had it looking pretty sharp.

The heart of the controller is an accelerometer housed in the project box that reports the value of the X axis to the Arduino so that the client can signal that it is moving left or right.  Mounted on the box are four LEDs and a momentary switch.  Two of the LEDs indicate tilt, red lights for left (port) and green for right (starboard).  The switch is used to connect and disconnect from the server.  One of the other two LEDs lights when the button is pushed and the other stays on when connected to the server.

Painted Leaf SpringI had the box built and ready before finding the leaf spring and it worked well tilting it in my hands.  I ran into trouble, though, when using the spring.

The controller was not working properly and at first the readings seemed to be different depending on how the Arduino was powered.  The final product would be powered by a 9V battery, but of course had to be plugged into USB to see the readings printed to the serial port.  The accelerometer is a 3.3V device and sits behind a voltage regulator, so even though its output is ratiometric to the input voltage, they  should not have been different for either power source in this circuit.  I metered the output of the regulator as a sanity check and sure enough it was a steady 3.3V.

After a while I figured out that the readings were not different depending on the power source as long as I reset the Arduino after unplugging the USB.  The real problem with the rig was that the curve of the section of spring that I found was not sufficient to tilt the accelerometer enough for meaningful readings.

Rebuilding the Controller

Found WoodWhile walking near my house one day, again wondering what to use for the controller, providence smiled on me again when I saw two pieces of wood nailed together and left by the side of the road.  I brought it home, painted it my now trademark red and attached the box with Velcro.  A 10 lb. dumbbell that happened to be in the house proved to be a perfect fulcrum, giving the box plenty of tilt.  I was in business.

Painted WoodThe server software listens for clients and when they connect their paddle is added to the screen, either on the top or bottom team.  In the book Igoe builds a second client using parts of a stepper exercise machine.  I choose not to build a second client to play head-to-head since the cost of a second Arduino and Ethernet module was prohibitive.  I played against the seesaw client using a laptop connected to the server via FTP.

Controller by Mennen

Softpot ControllerIn my never ending quest to recycle plastic deodorant containers I did end up building a second controller with a spent Speed Stick style container and a SoftPot.

I got it in my head that the built-in mechanism for moving the deoderant up and down could be used for something and eventually came up with the idea of using the SoftPot.  When the dial at the bottom of the container is turned, the plastic piece that used to hold the deodorant runs along the SoftPot.  I got good readings after padding the plastic piece with some electrical tape to make better contact.

Playing PongWhen I received the SoftPot I was disappointed to see that it was about a half inch longer than the container, so it did not look as slick as I wanted.  I used wrapping wire to connect the pins of the SoftPot to some header pins and plugged right into the breadboard in the box that I used for the seesaw controller.  It might not have looked like I wanted, but it worked well.

Reflections

Foot ControllerWhile I originally thought that the dollar store plastic container was a good project box, if I had to do it over I would use something else.  The trouble was that every time I had to open the box there was the danger of disconnecting wires from the breadboard, since the lights and switch were mounted on the top.  Jostling the accelerometer was not helpful, either.  Maybe I should have used something hinged and planned the wiring better.

 

 

Parts Bin

Parts Bin

3 axis Accelerometer

from SpartFun

Ethernet Shield

from Adafruit

SoftPot

from Adafruit Industries