We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, I am doing a brainwave eeg project now and I have already got the raw brainwave values in Arduino. It is a string of 11 values. But when I want to parse the eeg string in processing, I got the error 'disabling serialEvent() for /dev/cu.usbmodem1411 null'. I am quite new to processing and I totally have no idea about that. Is there anyone could help me to see this code? Thanks in advance. Sorry for my English if there is any mistake.
PS: I even didn't get the 11 varying values in the below monitor. I can only get data like this: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Here is the code:
import processing.serial.*;
Serial serial;
int signal_strength;
int attention;
int meditation;
int delta;
int theta;
int low_alpha;
int high_alpha;
int low_beta;
int high_beta;
int low_gamma;
int high_gamma;
void setup() {
println("Find your Arduino in the list below, note its [index]:\n");
for (int i = 0; i < Serial.list().length; i++) {
println("[" + i + "] " + Serial.list()[i]);
}
serial = new Serial(this, Serial.list()[3], 9600);
serial.bufferUntil(10);
}
void draw() {
println(signal_strength, attention, meditation, delta, theta, low_alpha, high_alpha, low_beta, high_beta, low_gamma, high_gamma);
}
void serialEvent(Serial serial) {
String incomingString = serial.readString().trim();
int[] incomingValues = int(split(incomingString, ","));
signal_strength = incomingValues[0];
attention = incomingValues[1];
meditation = incomingValues[2];
delta = incomingValues[3];
theta = incomingValues[4];
low_alpha = incomingValues[5];
high_alpha = incomingValues[6];
low_beta = incomingValues[7];
high_beta = incomingValues[8];
low_gamma = incomingValues[9];
high_gamma = incomingValues[10];
}
Answers
First thing, make sure you are connecting to the right serial port.
You should consider checking the following posts and the provided links there: https://forum.processing.org/two/discussion/comment/101770/#Comment_101770 It is important that you make sure to handle cases where the serial event return null when retrieving data.
You only get 0 for all your values? What do you get from the code below? Notice: Code below is untested.
Kf
Hi kfrajer , thanks for your advice. I have tried the above code and get the result like this:
I am sure I am using the right serial port. Do you have any other advice?
I am guessing you have the right port. Can you share your ino code?
You can check what you get in every event:
After you check what you receive, then you could process only those lines with 11 items.
Kf
Kfrajer, thanks a lot, I fixed it finally.