Code

bootstrap.cC/C++
bootstrap.c
// Eric's notes:
// You can get the signal strength, attention, and meditation values directly by 
// calling the scoutscript:  `print brain.signal`, `print brain.attention`, or 
// `print brain.meditation`.
// This was made by mashing up the Brain library (https://github.com/kitschpatrol/Brain)
// with the Pinoccio bootstrap (http://pinocc.io/solo).
// First, download and install the "brain" library. Then, paste this code into the Arduino IDE,
// save it as a sketch, and upload it to your Scout.

#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include <Brain.h>
#include "version.h"

// hook up the Neurosky to Serial 1 (RX1/TX1)
Brain brain(Serial1);

void setup() {
  Scout.setup();

  // Add custom setup code here

  Serial1.begin(9600);
  addBitlashFunction("brain.signal", (bitlash_function)signal);
  addBitlashFunction("brain.attention", (bitlash_function)attention);
  addBitlashFunction("brain.meditation", (bitlash_function)meditation);
}

void loop() {
  Scout.loop();

  // Add custom loop code here

  char buf[32];

  // Expect packets about once per second.
   if (brain.update()) {
    Serial.println(brain.readErrors());
    Serial.println(brain.readCSV());

    // signal
    snprintf(buf, sizeof(buf), "on.brain.signal(%d)", brain.readSignalQuality());

    if (findscript(buf)) {
      doCommand(buf);
    }

    // attention
    snprintf(buf, sizeof(buf), "on.brain.attention(%d)", brain.readAttention());

    if (findscript(buf)) {
      doCommand(buf);
    }

    // meditation
    snprintf(buf, sizeof(buf), "on.brain.meditation(%d)", brain.readMeditation());

    if (findscript(buf)) {
      doCommand(buf);
    }
  }
}

numvar signal() {
  return brain.readSignalQuality();
}

numvar attention() {
  return brain.readAttention();
}

numvar meditation() {
  return brain.readMeditation();
}

Credits

Photo on 7 5 17 at 5 06 pm 7 05huowsyxv
Alex Glow

The Hackster team's resident Hardware Nerd. I like robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

DHT22 Sensor and Pinoccio
  • 1,622
  • 5

Full instructions

Using DHT22 Temperature and Humidity sensor with Pinoccio

Human Presence Detection & Visualization
  • 1,070
  • 9

Full instructions

Team Cogitate's social radar displays people nearby as a set of glowing orbs

Hideous Arc Reactor Sweater (WIP)
  • 842
  • 7

Work in progress

Power through the holiday slump with this festive, EEG-reactive sweater!

Pinoccio Craft
  • 378
  • 5

Full instructions

Send Bitlash Pinoccio Commands through Minecraft.

Solar Powered Pinoccio Scout
  • 1,101
  • 9

Run your wireless mesh forever with Adafruit's solar LiPo charger

Pinoccio Programming in Minecraft
  • 1,928
  • 6

Add custom ScoutScript blocks in your virtual domain—then see the real-world effects!

Add projectSign up / Login