This week, I made a game controller for the Lunar Lander game.
I started by identifying which controls were needed by playing the game.
- click to start game
- left arrow to rotate clockwise
- right arrow to rotate counter clockwise
- up arrow to fuel the rocket
- “s” to speed up the game
Next, I looked at what kind of interaction I wanted the user to have while playing the game. I started with some designs where the controls would sit on a table top. I thought this was too similar to the original experience of using the keyboard, so I wanted to make it hand held. Here are my sketches where you can see the progression of my ideas.
I decided on design 1 on the right side of the page next to the poorly drawn hand. I thought this was more familiar hand position like playing a GameBoy or holding a camera. First, you would push the knob to start the game. Once the game starts, you can turn the knob with your left hand to rotate the moon lander. Holding down the button on the front with your right thumb will fuel the lander, and finally you can speed up the game by pressing the button on top with your right index finger. I figured some dimensions for something that would fit nicely in someone's hand. Flattened box dimensions are shown in inches below.
Next, I figured out that code that would need to accompany the hardware I chose. Here is my breadboard circuit. I am using the Arduino Micro.
And here is everything packaged into my cardboard enclosure.
I am using a rotary encoder which also has a momentary button when you push down on the knob. It has very distinct feeling clicks when you turn the knob, so I thought this would be nice to control the rotation of the lunar lander with precision. I used the library Encoder by Paul Stoffregen. When I tested the rotary encoder’s output, I saw that each “click” when turn the knob made the position variable go up in increments of 4.
So then, in my code I made it so that each “click” rotated the space ship by pressing the arrow keys for 50 milliseconds. The buttons were more straightforward to program, and you can have a look at my code below. I relied on the Keyboard.h and Mouse.h libraries from Arduino.
Finally with everything working, I assembled everything into my little cardboard enclosure. The rotary encoder's shaft's diameter was 0.235", which (very exciting) meant I could use a 15/64" drill bit to make my own press fit knob. I just used the 15/64" bit, kept the same placement and then used a hole-saw bit to drill out the knob. I made it pretty quickly with scrapwood, but it opens up some options for creating better custom knobs in future projects.