To write the code, we first required the code which is needed to use the mpr121 breakout board. We got the code from this website:
We then changed the code around so that it can incorporate our use of LEDs, the button and the shocker that we made. To see the changes to the code, visit this gitlab link:
The changes we made were done in the mpr121.ino file given to us through the bildr website. The red rows were our deletions and the green rows were what we added to the code to make it work how we wanted.
When the vest is finished you should have the following outputs:
- 8 LEDs
- 2 Shock wires (Need both to be connected to one hand to be shocked)
The inputs on the vest are:
- The targets (4 in our case)
- The reset button
You can connect a power-bank to your Arduino Uno to power the circuit.
The complete vest
The circuit after following the schematic design
The underside of the circuit
This is the schematic design to follow when trying to connect the Arduino Uno, the MPR121 breakout board and the modified shock gum toy.
There is also a push button included which is used to reset the LEDs when you have run out of lives. Pins 3 – 10 are used connected to the cathode of the LED and the anode is connected to a 220 Ohm resistor which is then connected to Ground. Pin 11 is used for the push button which is used as an INPUT so the function digitalRead will be used with it.
Also, as you can see the shocker has 3 ouput wires, two of the wires have to be connected to each other so that essentially you have two wires which will generate the shock. In the image below, the blue wire (OUTPUT A0, A1, A2) is connected to the pink wire. The brown wire is the standalone output wire. If both sets of output wires are touching each other, the shock will not work. Finally, the green wire is the Ground wire.
Shock Gum – Rewired
As we require a high current for a person to get shocked, we have to use three arduino pins as output pins as 1 or 2 pins do not provide enough current for a person to feel a shock. This is why we used the pins A0, A1 and A2 on the Arduino Uno as output pins for the shocker, so when the target gets hit, we use digitalWrite HIGH on all three of these pins.
To make the target we did these following procedures:
- Draw out the targets
- Wire up the targets connecting the target to the MPR121 board
- Tape over the visible wire using copper tape
- Place cardboard over the copper tape
- Tape over the cardboard with copper tape again
This allows the targets to be quite rigid so that the targets do not accept a crease in the vest as a hit.
The Cardboard with the second layer of copper tape
The first Target copper layer
The wires from the MPR to the Target
The MPR board
The target with the cardboard on it