Game Controller

For this assignment, I created a game controller to play Atari’s Lunar Lander game in a browser. Using buttons, the controller sends W(up), S(down), A(left) and D(right) keypresses as a USB keyboard.

I used the MKR1000 board for this assignment. The device uses bluetooth connection but I connected it via USB directly to the computer for power and connection.


#include “Keyboard.h”

const int upButton = 7;
const int downButton = 8;
const int leftButton = 6;
const int rightButton = 9;
//const int reloadButton = 4;
//const int enterButton = 5;
void setup () {
pinMode(upButton, INPUT);
pinMode(downButton, INPUT);
pinMode(leftButton, INPUT);
pinMode(rightButton, INPUT);
// pinMode(reloadButton, INPUT);
// pinMode(enterButton, INPUT);


void loop() {

//keyboard button presses
if (digitalRead(upButton) == HIGH) {‘w’); //send UP
else if (digitalRead(upButton) == LOW)

if (digitalRead(downButton) == HIGH) {‘s’); //send DOWN
else if (digitalRead(downButton) == LOW)

if (digitalRead(leftButton) == HIGH) {‘a’); //send LEFT
else if (digitalRead(leftButton) == LOW)

if (digitalRead(rightButton) == HIGH) {‘d’); //send RIGHT
else if (digitalRead(rightButton) == LOW)

Circuit Design



Bamboo box


Solder header pins to the MKR1000
Solder wires to the 4 buttons
Connect the buttons and MRK1000 to breadboard



Arduino mouse and keyboard libraries

Arduino mouse button control

31 thoughts on “Game Controller”

  1. I happen to be writing to make you understand what a terrific experience our princess went through visiting yuor web blog. She realized such a lot of things, with the inclusion of what it is like to possess an incredible teaching style to make the others without hassle thoroughly grasp various tricky topics. You undoubtedly surpassed visitors’ expected results. Thanks for showing those valuable, trustworthy, revealing not to mention unique tips on your topic to Sandra.

  2. Thank you for each of your hard work on this web page. My aunt really likes going through investigations and it’s really obvious why. Most of us learn all of the lively method you offer practical strategies through this web site and even increase participation from some other people on the issue so our favorite girl is in fact learning a lot of things. Take advantage of the rest of the year. You are always doing a really good job.

  3. I am glad for writing to make you know what a notable encounter my wife’s girl had studying your web site. She mastered several pieces, which include what it’s like to possess an awesome helping nature to let other individuals with ease know precisely some problematic subject matter. You truly exceeded people’s expectations. Thank you for producing these practical, trusted, informative and in addition fun tips about this topic to Kate.

Leave a Reply

Your email address will not be published.