Monday, February 3, 2014

Load up the Arduino with mind flex code for serial data out

Posted by rinson
Download and install the Arduino Brain Library — it’s available here. Open the BrainSerialOutexample and upload it to your board. (You may need to disconnect the RX pin during the upload.) The example code looks like this:
  1. #include
  2. // Set up the brain parser, pass it the hardware serial object you want to listen on.
  3. Brain brain(Serial);
  4. void setup() {
  5.         // Start the hardware serial.
  6.         Serial.begin(9600);
  7. }
  8. void loop() {
  9.         // Expect packets about once per second.
  10.         // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
  11.         // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"   
  12.         if (brain.update()) {
  13.                 Serial.println(brain.readCSV());
  14.         }
  15. }