i am trying to connect my mindflex to my pc via arduino leonardo but i can't seem to make it send data packages to my serial monitor... Any idea what might be the problem? i did everything as described in the video tutorial but nothing shows up in my serial monitor..
No clue what you're talking about.
Link the schematic and code.
it is the project shown here : How to Hack Toy EEGs | Frontier Nerds
i follow the instractions completely but when it is time to start getting data in serial monitor it just shows nothing...
i double checked the connections i soldered and everything is good...
the code is this :
// Arduino Brain Library - Brain Serial Test
// Description: Grabs brain data from the serial RX pin and sends CSV out over the TX pin (Half duplex.)
// More info: GitHub - kitschpatrol/Brain: Arduino library for reading Neurosky EEG brainwave data. (Tested with the MindFlex and Force Trainer toys.)
// Author: Eric Mika, 2010 revised in 2014
#include <Brain.h>
// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);
void setup() {
// Start the hardware serial.
Serial.begin(9600);
}
void loop() {
// Expect packets about once per second.
// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
// "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"
if (brain.update()) {
Serial.println(brain.readErrors());
Serial.println(brain.readCSV());
}
}
Do you know if the program is designed to work with a Leonardo?
My suspicion is that the different Serial system on the Leonardo is getting in the way.
Try adding while (! Serial); immediately after Serial.begin(9600);
...R
I asked the author of the brain library and here is the solution:
This is probably an artifact of how the Leonardo handles serial, and the half-duplex communication used in the brain library's example projects. Unlike most of the basic Arduino boards, the Leonardo's USB serial connection is separate from the connection provided by the header pins. From the documentation:
The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 >(TX). Serial is reserved for USB CDC communication.
You can probably work around this by "reading" from the Neurosky on Serial1 (the header pins connected to the Neurosky), and "writing" to Serial (the USB cable connected to your PC).
Try this:
#include <Brain.h>
Brain brain(Serial1);
void setup() {
Serial.begin(9600); // Leonardo's USB
Serial1.begin(9600); // Leonardo's TX/RX pins
}
void loop() {
if (brain.update()) {
Serial.println(brain.readErrors());
Serial.println(brain.readCSV());
}
}
7s10u:
The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 >(TX). Serial is reserved for USB CDC communication.
Oops. I had overlooked the difference between Serial and Serial1 in my earlier post.
The Leonardo has no pins connected to Serial. Pins 0 and 1 are connected to Serial1.
You should always put
Serial.begin(9600);
while (!Serial);
when using a Leonardo - it allows time for the Serial connection to be esatblished.
On a Leonardo the baudrate for Serial is irrelevant (but probably needed to keep the compiler happy) as it always communicates with the PC at full USB speed.