Week 1 : Game controller with HDI output

Assignment: Game controller with HID output

Make a device to play Atari’s Lunar Lander game in a browser. Here’s a different version that uses the up, down, left and right arrows. Your device should support the following actions:

  • Send up, down, left, right keypresses, or W, A, S, D keypresses as a USB keyboard
  • Send mouse clicks
  • Move mouse in X and Y direction to desired location to click
  • Your controls should be arranged so that the player can watch the screen, not concentrate on the controls

Make a housing for your controller. Document it according to the project documentation guidelines at the end of this page.

My finished project

Process

  1. Arduino Micro Board

I started from exploring the different boards that is available in ITP shop and got Arduino Micro which simply keyboard and mouse recognisable by USB built-in. Arduino comes with Keyboard and Mouse library so I tried to see if the simple function works first.

Code

 

//include the libraries

#include “Keyboard.h”

#include “Mouse.h”

//set pin numbers

const int upButton = 3 ;

const int downButton = 4;

const int leftButton = 5;

const int rightButton = 6;

const int mouseButton = 7;

void setup() {

 // put your setup code here, to run once:

pinMode (upButton, INPUT);

pinMode (downButton, INPUT);

pinMode (leftButton, INPUT);

pinMode (rightButton, INPUT);

pinMode (mouseButton, INPUT);

 

Serial.begin(9600);

// initializa mouse control

Mouse.begin();

Keyboard.begin();

}

void loop() {

// use serial input to control the keyboard :

if (digitalRead (upButton) == HIGH )  {

 Keyboard.write (‘w’);

 }

 if (digitalRead (downButton) == HIGH ) {

   Keyboard.write (‘s’);

 }

 if (digitalRead (leftButton) == HIGH ) {

   Keyboard.write (‘a’);

 }

 if (digitalRead (rightButton) == HIGH){

  Keyboard.write(‘d’);

2. Circuit board
I wired the circuit board by hooking up each pin to buttons and one for the mouse and since ITP shop doesn’t have 10k ohm resistor so I wired 20k ohm pararelly. 

The result: the button took over my keyboard and caused my computer to shut down, S A D.

I then realised later that I need to remove the mouse from the code and get the keyboard work first and added 10k ohm resistors to each button, recheck the electricity and connectivities and tried again.

using this code 

I went through all wiring and code again and again and suddenly it worked !

3. Design 

I thought about user experience and interaction by looking at the human’s behavior and grip and come up with the idea of having the controller round and easy to grip. Adding buttons to the location where fingers can travel easily. Then I hide the whole breadboard inside of the box.

4. Class demonstration. 

What I’ve learned  

  • That I should really plan the schemic of the circuitry first then wiring electronics, not the other way round.
  • Learned to think about the design sooner, not later. UX played a big part as much as getting the circuit and the code to work.
  • Test with the real user
  • Prepare the wires, adaptors, materials that I need before hands. I’ve spent almost 2-3 hours finding the right dongle, adapter and wires to the new macbook pro (2016) which was a pain.

 

 

 

 

Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *