How-To Build Your Own Brain Bats Game

From Hack Manhattan Wiki
Jump to: navigation, search

How-To Build Your Own Brain Bats Game

Materials Required

  • Neurosky MindWave Headset (MindWave Mobile, the Bluetooth version, may also work on some platforms)
  • Arduino Uno, Arduino Duemilanove, or an Arduino clone, and USB cable
  • LoL Shield
  • Computer with Python 2.7 installed, along with modules pygame, pyeeg, pyserial, pybluez and scipy

Software Required

Assembly Instructions

Only the LoL Shield actually needs assembly. LoL Shield is 9×14 array of LEDs. To directly address each of 126 LEDs, so you can turn each one on or off without affecting any other LEDs, you would ordinarily need 126 pins on your Arduino. The traditional method of multiplexing requires a pin for each row and a pin for each column, or 9+14=23 pins. An Arduino only has 20 pins, so the creator of LoL Shield uses Charlieplexing, which exploits the tri-state logic of microcontroller pins to control more LEDs than you would traditionally be able to.

LoL Shield is relatively simple to assemble if you know how to solder, but it is of course very tedious to solder the 252 leads. Just make sure the LEDs are oriented correctly. The easiest method is to make sure the flat side of the LED's plastic casing is aligned with the flat edge on the LoL Shield silk screen.

A charlieplexed display will have display "ghosting", where certain pixels are dimly lit even though they shouldn't be lit at all. This is unavoidable. On an Arduino, there is the additional problem that pin 13 is connected to an on board LED, which is actually the LED that's blinked by the familiar blink sketch. The current limiting resistor on that pin makes some pixels on the LoL Shield permanently dim. If you know how to solder and desolder surface mount components, or are creative and fearless with a good knife, this problem can be solved by removing that LED and its resistor.

  1. Fit LoLshield onto Arduino
  2. Plug in USB cable to Arduino and computer
  3. Upload sketch to Arduino using the Arduino IDE
  4. Plug in Mindwave serial dongle to USB port
  5. Wear Mindwave headset and turn on.

Running the Game

The game software has two components: a Python program that runs on your laptop, receives values from a NeuroSky headset, and sends attention scores to an Arduino, and

  1. At the command line, run 'python pong.py serial'.
  2. Press F5 to connect the headset
  3. You should see a flashing green light if the connections are all good, and raw data flowing along the bottom.
  4. Play Brain Bats by maintaining a high attention value.

Troubleshooting