Introduction: Arduino Leonardo Game Controller for Quadriplegics

I created this assistive device as a project for my engineering class. The assignment that we were given was to create an assistive videogame controller for quadriplegic individuals. During the time leading up to this assignment, we learned basic Arduino code, circuit creation, soldering, and laser cutting. We were given many basic materials such as wood, cardboard, breadboards, buttons, wires, and an Arduino Leonardo. The point of using low-cost materials was to allow our controllers to be accessible to everyone. Most assistive tech on the market at the moment is extremely expensive. For this reason, it was important that we could keep the cost of this project as low as possible.

Supplies

Materials:

  1. Arduino Leonardo x1
  2. Breadboard x1
  3. Breadboard jumper wires
  4. Momentary tactile tact push button x3 (I would buy a few extra because sometimes the leads snap off)
  5. Micro USB
  6. Green 5mm LED x1
  7. 16in by 12in by 1/4in baltic birch plywood x2 (This material is only necessary if you plan on making the structure and buttons out of laser cut pieces. I personally used the laser cutter at my school but I understand that for a lot of people a laser cutter is not something they have access to. Instead you could used cardboard and an exacto knife to cut out the pieces from the attached svg files.)
  8. Tape

Tools:

  1. Hot glue gun + hot glue sticks
  2. Soldering iron + solder
  3. Laser cutter (needs to be able to cut 1/4in ply)
  4. Small needle-nose pliers

Laser Cuttings Files:

  1. Main structure/circuit housing
  2. Button structure
  3. Button supports

Code:

  1. Arduino code
  2. Space invader code (HTML/JAVA/CSS)

Programs:

  1. Arduino Ide

Step 1: Laser Cut Pieces

This is one of the more simple steps. For this step you have to download the files from the supplies section under the Laser Cutting Files section. All of these files is an svg. which means that it can be put into a program like adobe illustrate and exported to a laser cutter. Every laser cutter uses a different program so you may have to put the files in a different place depending on what program corresponds with the laser cutter that you are using. An important thing to remember is not to change the scale or size of any of the pieces. All of these pieces should be cut out of 0.25in plywood. Once the pieces are cut out you should be left with 19 different wooden parts.

Box Assembly:

The box is made of six different interlocking pieces. One of the two large faces of the box has six holes in it, this face should be left off until the circuits have been fully assembled. The remaining five pieces of the box should be fitted together. If the pieces do not fit tightly together you may want to add a bit of glue to the corners so that is doesn't fall apart.


Step 2: Button Assembly

In this step you will assemble three button units. The parts that you will need will be all of the laser cut pieces from the button structure file, three momentary tactile buttons, and 6 male to female jumper wires. The tools that you will need will be a hot glue gun + glue and a soldering iron + solder.

Left and right button construction steps:

  1. Grab one of each pieces that you cut out from the button structure file (one flat piece with four holes, one rectangle with the entire center missing, and one smaller rectangle that fits into the center of the previous piece)
  2. Imagine that you are making the button structure from bottom to top
  3. Place the rectangle with holes flat on the table
  4. Place the rectangle with the center missing on top of the rectangle with the holes and align them, then glue them together
  5. Grab one button and two male to jumper wires
  6. Bend the 4 leads of of the button flat
  7. Solder one end of the male to male jumper wire to one of the button leads, then on the same side of the button solder another male to male jumper wire
  8. Glue the button down in the position corresponding to the diagram above labeled "Inside of button unit left/right"
  9. Feed the wires through the whole closest to the button
  10. Place a small dot of glue on the black top part of the button and place the smallest rectangle on top of the button and inside of the rectangle with the center missing
  11. Then place small piece of tape of the side opposite of the button so that the unglued side does not separate from the main structure of the button
  12. repeat so that you end up with two of these specific buttons

Center button structure:

  1. complete steps 1-7 of the steps from the previous instructions
  2. glue the button down according to the diagram above labeled "Inside of center button"
  3. complete steps 9-11

Step 3: Arduino and Wiring

For this step you will need 8 male to female jumper wires, one arduino, one small breadboard, and one small green led light. You will need to remove the small black piece of plastic from the male end of all of the jumper wires. Once the plastic piece has been removed bend all eight male ends of the wires at a 90 degree angle (image of bent wires). Then insert the bent male ends of the wires into the ports according to this wiring diagram. The three wires connected to the digital ports of the arduino and the other three wires connected to the negative terminals on the breadboard will be set aside until the final assembly step. The remaining two wires should be connected to the led, positive to the long wire of the the led and negative to the short wire. Push the wired led into the small round hole at the top of the box.

Step 4: Final Assembly

In one of the earlier steps you laser cut four triangles, it is finally time to use those. Glue the side buttons to the triangles and then to the top of the box. Run the wires of the two side buttons through the holes in the top of the box. Run the wires of the center button through one of the center holes in the top of the box and then glue this button down. Once the male ends of the jumper wires have been run through the top of the box connect them to the six female ends of the wires that you set aside earlier. Connect the left button to port 3 and one ground, connect the center button to port 2 and ground, connect the right button to port 4 and ground. Insert a micro usb cable into the arduino and run it out of the box. Lastly make sure that all of the wires are contained within the box and then close the box.

Step 5: Arduino Code

Download the arduino IDE program linked in the supplies list. Then copy the code displayed below into the arduino program. Then upload this code to the arduino in your assistive controller.

#include "Keyboard.h"


const int buttonPin[] = {2, 3, 4};
int pinCount = 3;
int buttonState[] = {0, 0, 0, 0};
int prevButtonState[] = {HIGH, HIGH, HIGH};


long lastDebounceTime[] = {0, 0, 0};
long debounceDelay = 50;
void setup() {
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    pinMode(buttonPin[thisPin], INPUT);
    digitalWrite(buttonPin[thisPin], HIGH);
  }
  Keyboard.begin();
}


// Output actions. Probably the only part that you need to change
int outputAction(int currentButton) {
    if (currentButton + 1 == 1) {
      Keyboard.press('w');
      delay(100);
      Keyboard.releaseAll();
    }
    if (currentButton + 1 == 2) {
      Keyboard.press('a');
      delay(100);
      Keyboard.releaseAll();
    }
     if (currentButton + 1 == 3) {
      Keyboard.press('d');
      delay(100);
      Keyboard.releaseAll();
    }
}
void loop() {
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    buttonState[thisPin] = digitalRead(buttonPin[thisPin]);


    if ((buttonState[thisPin] != prevButtonState[thisPin]) && (buttonState[thisPin] == HIGH)) {
      if ((millis() - lastDebounceTime[thisPin]) > debounceDelay) {
        outputAction(thisPin);
        lastDebounceTime[thisPin] = millis();
      }
    }


    prevButtonState[thisPin] = buttonState[thisPin];
  }
}

Step 6: Space Invaders Code

Download the space invaders code from the supply list at the top of the page and open the java script file in textEdit on Mac. Delete everything from the java file and replace it with the content attached here. Then go back into the files and double click on the HTML file, this should open your browser and allow you to begin playing the space invaders game.