This is a game controller to play Atari’s Lunar Lander game in a browser
However, my initial idea was something different. From left to the right, it is consist of: a potentiometer (a, d) with a laser cut lunar lander on top of it. The orientation of this lander should match with the one in the game. Two buttons that represent increasing power and decreasing power respectively. A larger button that matches with the space bar. A joystick that enables the mouse movement and click.
I really want to make the potentiometer work so I tested that if I pressed the left arrow nine times, the lander will be on its left end, the same for right side. Thus, I created 18 states for the lander and then mapped the value to 0-18, like the illustration in the middle of my sketch below. However, it is really hard to achieve that same effect that the keyboard gives with what Arduino gives. This design ended up with a crazy keyboard either does nothing or prints tons of ‘a’ and ‘d’ in my text editor.
I decided to just use five buttons. During the process, I was totally confused by Keyboard.write() and Keyboard.press(). The device worked very well as a typewriter but it doesn’t work as a game controller in the game. My solution was to use Keyboard.press() and use Keyboard.releaseAll() when the user releases the button but I still don’t understand it.
Here is the enclosure design. I tried using standoffs. The part on the right was for the five buttons. It appears to be a supporter for all the five buttons. With this design, I ended up with no using hot glue at all 🙂