The assignment was to build a game controller to operate Atari’s Lunar Lander. Nothing about it seemed too complicated — simple circuitry, a bit of code and housing for the board, circuit and buttons. On Sunday I built the circuit using a pull down set up for each of the four buttons and keyboard write with the keyboard library.
This never fully worked. Some things worked and then didn’t. I tried changing it to pull up instead both on the board and in code. That changed nothing. I tried changing the board from the Arduino micro to the Feather MO which involved adding a new board to the Arduino software. That didn’t change anything, but caused me to redo the input numbers. The problem in switching from pull down circuits to pull ups and constantly changing the code led the boards to go wild and type without pressing the button. This was extremely frustrating and forced me to reset the boards — it happened with both the micro and the feather boards.
The truth is I have never established strong trouble shooting skills. When I’m feeling on the up and up, I’m usually patient enough to catch things, but I’ve been sick all week and this led to no patience. I decided to call it a day and try the next morning.
However, the next morning, I kept having similar problems. I showed the code to Tom Igoe along with the board. He caught flaws on both, but more importantly, he taught me a good order of operations for trouble shooting that I will do from now on. (NOTE: I also had thought of const int as a global variable, but Tom explained const is constant so if I want the variable to change during the code, it should not be declared a constant. Pretty obvious now that I think about it, but not obvious to me at the time.)
Before looking at the code, I need to check to make sure the circuit works. First, check to see the board has power going across all of it — it turned out mine did not because it had a loose wire. Second, make sure there are the correct voltage changes over each part. Then with the code, instead of making it affect the keyboard yet, print things to the serial monitor to make sure it works. Lastly make sure the code is working for real. I also learned the best way to trouble shoot a board especially when you are using a micro controller to control the keyboard is to have a blank sketch you can keep re-uploading while reseting the board.
I also learned from fellow students that the keyboard library using key pressed and key released was a better version of the code so I rewrote the code from scratch again.
And this finally got the game fully working, but now I need to make the housing. I decided the cute Adafruit box was the perfect size to fit my hands, but it would be hard to squeeze in all of the parts.
I borrowed the Feather MO board from the shop so I could not solder wires to it. Instead I found male to female cables and switched the rest of the parts onto a smaller breadboard. But I saw that my cables were too long to attach to the buttons and still fit in the box. The cables were also not a good type of wire inside to solder directly to the buttons. So I decided to use the tougher cable at the shop instead. I also thought the stiffness might help with the button presses.
At each point in this process, I kept testing the board with the game to make sure it worked. Fortunately it did and after soldering all of the cables and cutting little holes in the box with a straight edge for the buttons, I thought I was ready to go.
However, I made the holes based on UX design for the player. And although the stiff buttons were a good height, once I had to get all of the parts inside and position them, the cable was too tough and not quite lining up correctly. The cable I did not want to originally solder directly to the button ends was not as bad to use to solder to the stiff cable as an extension so that’s what I ended up doing.
It wasn’t pretty, but it allowed me to get all of the circuitry into the box and make it work. Note: I did cover all of the soldered parts with tape to make sure the wires would not interact with each other. And then finally, I had a working game controller! The problem remains that I am still total crap at the game, but that’s a problem for another day.