Background
This is based on FrontierNerds' Arduino + MindFlex hack. Our project is just as simple, but adds instant mesh networking to the system - empowering you to wirelessly control any hardware you want!
Without WiFi or Bluetooth, you can control as many Pinoccio Scouts as you own, simultaneously, all without going through a computer.
Of course, you do this at your own risk of voiding your warranty, ruining your headset, or exploding your workshop with the raw power of a mind unleashed.
In this tutorial:
- Hack your NeuroSky hardware
- Upload the Pinoccio sketch with controls for the NeuroSky
- Understand the data stream
- Control hardware with your brain!
- Pro tips
TL;DR: The two videos cover all of this with plenty of solid info to get you up and running, but the extra text will help you.
Hardware hack
A simple hardware mod connects the EEG reader to the Pinoccio. All you need is:
• 1 NeuroSky MindFlex brainwave reader*
• 1 Pinoccio Field Scout• Two short, solid-core cables (22-gauge should be good)
• Tools: Small screwdriver; wire cutter/stripper; soldering iron and solder
* Strangely, it is often cheaper to buy two MindFlex headsets instead of one. Just search for "MindFlex Duel".
Bootstrap
Programming + Connectivity Tips + Example Projects
Anytime a Pinoccio is hooked up with a cable in this video, it is simply in order to read the values directly through Arduino's serial monitor. You can unplug everything, and it will still run beautifully!
Interpreting the Data
Here, check out my first session with my hacked MindFlex!
An example line for you:
0,51,37,1174945,149951,12446,51899,33225,35075,24428,3816
Let's go through each of the comma-separated numbers.
1. Signal status (0-200)0 means "perfect signal", and 200 means "no signal".
This value likes to hover around 25-26, 50-51, and 80-86.
The higher values tend to mean that either the forehead sensor or the earlobe clip is disconnected.
Lower values usually indicate that you have the forehead sensor placed poorly, or that you need to clean the sensing areas (your skin and the headset's contacts) to improve conductivity.
2 & 3. "Attention" and "Meditation" values (0-100)Here, 0 is the worst, and 100 is the best performance this headset can measure.
Check the tips above for ways to improve these readings.
If Signal is not 0, these values will remain the same until perfect connectivity is reached again, so if your values are frozen, try wiggling the forehead sensor, pushing on it with your finger, or adding moisture between your skin and the sensor contacts.
4 - 11. Frequency bandsCheck out Frontiernerds' description of what these values correspond to. Basically, the readings range from low-frequency waves of voltage in the brain (delta waves, associated with sleep) all the way up to 50Hz gamma waves. Darren Mothersele has also managed to extract the raw data from the headset. We don't use these in this project.
Code examples
Here's the code from the video above, in friendly, copy/pastable form.
Save this function to the brain-linked Scout:
function sendatt { a = brain.attention; mesh.announce(1,a); };
Then, set it to run once per second (1000 ms):
run sendatt, 1000;
Change the indicator to the Meditation value by using "m = brain.meditation" instead of "a" for Attention.
If you have another Scout in the same troop, save this function to make it light up its LED in blue. The brightness indicates the strength of your concentration:
function on.message.group { a = arg(3); a = (a / 2) * 5; led.setrgb(0,0,a); }
Or, upload your brain! This function prints the Attention value to that Scout's console in HQ:
function on.message.group { a = arg(3); hq.print(key(a)); };
You can indent, add line breaks, or neither - either way, when you add the function to your Scout, it will be saved as a single line and work the same. Just be liberal with semicolons, and watch out for brackets vs. parentheses.
Now, here's the code for the Scout driving a mini-helicopter (Beginner's Mode):
function on.message.group { a = arg(3); if (a > 70) { pin.write("d4", HIGH); }; if (a < 70) { pin.write("d4", LOW); }; }
Crank up the difficulty by raising the threshold to 80% or higher, as you advance in your mental agility training.
A couple of caveats when working with this project:
- Use small motors, and test them first to make sure you don't burn out your Scout. It happens, and it's smelly. (If you DO burn out the charging transistor, and the charge cable gets hot, unplug it immediately. It may stay hot even when the Scout is turned off. You may still be able to run the board for short periods by plugging the cable back in again.)
- I've found that using separate "if" statements in the code works better than "else". Bitlash is an evolving tool, so this should improve in the future.
Max Out Your Brainpower
Here are some methods you can try, to keep breaking the limits on your focus and relaxation.
Maximizing Attention:
- Listen to an unfamiliar song and try to transcribe the lyrics.
- Count backwards.
- Think of large numbers and add or multiply them in your head.
- Write emails.
- Test out a brain-training or language-learning app. See if you're being challenged too much or not enough! How long can it engage you?
Maximizing Meditation:
- Alpha waves, those associated with calm and relaxation states, rise quickly when you close your eyes.
- Think of a calm and pleasing situation - floating on a raft, say, on clear water, with the sun warming your skin.
- Contemplate your happiest moments.
The "sweet spot" for brain activity comes when you're rocking both mental states: focused relaxation, also known as being "in the zone".
You'll find that, as you train more, you start to recognize the states that correspond to these readings. Congratulations; you're now better able to challenge yourself, and keep your brain healthy and engaged!
Or maybe you don't fully trust the readings you get... but at least you've found a fun new way to control robotic projects. :)
Have fun!
- Alex
Comments