[ITP: Understanding Networks] Networked Game Controller

Background

This weekend I made a game controller for Tom Igoe’s ball drop game. The Arduino Nano 33 IoT board we got in our PComp kits includes a Nina W102 uBlox module which supports WiFi connectivity so it was a no-brainer that I would use that. I’ve never made a game controller before so I looked to past students blog’s for reference.

I loved the this example and the control interface Beverly Chou developed that I wanted to do something similar. It’s kinda surprising that I’ve never encountered rotary encoders with my background before so I was interested in learning how to use them for my controller.

Circuit

Even though all Arduino nano 33 IoT pins should have external interrupts, I could only get the second encoder to work on pins 8 and 9. At this point I am not sure why that is.

Process

First I wanted to make sure I could get my hardware set up working. I started by bread-boarding the encoders and testing their functionality with Serial.println()’s. The blue knob sends the commands that moves the paddle up (CW) and down (CCW). The yellow knob sends the commands that moves the paddle right (CW) and left (CCW). I also needed to add a button to connect and disconnect from the network but I quickly ran out of space on my small bread board. These encoders have a push button built in, so I connected the blue knob’s button to the Nano 33 to establish a connection to the network.

Next I needed to send the game commands over the network using a TCP socket. With some digging I found the WiFiNINA library and examples. Then I found that Professor Igoe already wrote the WiFi joystick client, so I guess it pays to read the instructions fully….

After this, finishing up the code was a breeze. I added in the print functions to the client where they needed to go. I did get this weird error on my first compilation but I got rid of it by just updating the Arduino SAMD boards package.

Code

You can find the code and it’s iterations here.

Trouble-shooting and Future Work

So far I’ve been getting kinda weird readings from the encoders. I think this is because the encoders don’t really sit in the bread board right. I’d like to solder wires to them and mount them onto an enclosure. I’ve ordered some protoboard and female headers to recreate this circuit to fit in an enclosure. I found a mint tin on the junk shelf at school but it might be too small.

I’m also not sure how get the game running and get my controller interfacing with it. I’m sure we’ll go over that in class!

Here’s a link to my next blog post working on this game controller.

Resources

https://store-usa.arduino.cc/products/arduino-nano-33-iot

https://www.sparkfun.com/news/2438

https://learn.adafruit.com/rotary-encoder/hardware

https://www.pjrc.com/teensy/td_libs_Encoder.html

https://tigoe.github.io/BallDropGame/

http://itp.fromjia.com/?p=440

https://itp.beverlychou.com/websocket-game-controller/