The software is probably the simplest part of the whole project, and experienced Arduino programmers should feel right at home loading this onto their boards. Note that this will typically be a two-step process, however. First you'll need to change the #define MACADDR line to contain your Bluetooth module's MAC address; next flip the #define PROGRAM variable to 1. This will program the attached Bluetooth module to automatically scan for the MAC address you just entered whenever it's not paired, which is the preferred mode of operation. However, it will not parse any of the data; that comes in the second step.
Note that if this is the first time you've ever programmed your BlueSMiRF, or if you've recently reset it to the factory defaults, you'll also need to change the #define BTBAUDRATE line to be 115200 instead of 57600. This is because the default bitrate for the BlueSMiRF is 115,200bps, and we want it to be at 57,600. If the Bluetooth module is in its factory state, the program needs to know what speed to communicate at. However, once the Arduino has programmed the BlueSMiRF module once, the communication rate should stay at 57,600 (even if you program the BlueSMiRF again).
Once the Bluetooth module has been programmed, set the PROGRAM variable back to 0 (and the BTBAUDRATE back to 57600 if applicable). Now if you load the program onto your Arduino, the Bluetooth module should spend just a few seconds connecting to your headset and data should start getting read a few moments after that.
Other Useful Features
Astute programmers will notice there are several other useful variables in the software. For starters, you can adjust the level at which the Arduino will fire by changing the FIRE_THRESHOLD value. This is based off the attention value read from the NeuroSky headset, and valid levels range from 1-100. A level of 40 should be fairly easy for untrained subjects to attain.
You can also adjust the level at which the signal is considered "good." By default this is 200 on a scale of 1-255. Counterintuitively, a lower signal value is better, so a POOR_QUALITY_THRESHOLD of 25 is a stronger signal than a level of 250.
There are several other, less useful switches that can be set. ONTHEFLY can be set to a non-zero value to make the Arduino attempt to connect once on startup rather than anytime the device is unpaired. Be sure to set the PROGRAM value to 0 if you do this.
You can set the TERMINAL value to 1 if you want to use the Arduino as a pass-through device for querying the status of the BlueSMiRF or issuing commands directly to it. This will kick the BlueSMiRF into command mode as soon as the Arduino starts up, and any commands you issue will be relayed to the module (and any feedback from the module will be relayed back to the Arduino serial terminal). Be careful, though! Once you exit command mode with the --- sequence, you won't be able to re-enter it unless the Arduino is reset. This also requires that the NewSoftSerial library is installed, the Bluetooth module is set to TX and RX pins 2 and 3 respectively, and the HARDSERIAL value is set to 0.
The HARDSERIAL variable will determine whether to use the built-in Serial library (on pins 0 and 1) or the NewSoftSerial library for communicating with the Bluetooth module. While the hardware Serial port is highly recommended for normal operation, you'll need to set this to 0 if you ever want to send data from the Arduino to both the computer and the Bluetooth module, such as in the case of terminal mode.
Finally, DEBUG is available for those who wish to modify the code. Increasing values will give increasingly detailed debug information. Currently the most verbose level is 3.