I am attempting to use an Arduino to connect to a Mindflex headband that I attached the T pin to the RX pin on an arduino and then grounded them. I then have opened an RC car controller and soldered leads to the test points that correlate to the forward and backward buttons on the RC car controller. I am trying to get my code to read the attention or meditation values and based on the if statement move the RC car. I have two questions can you take a look at my code and see where I am going wrong these are the two things that I was wondering.
(brain.getCSV()) outputs this function returns a string 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”
I just want to target the first 3, signal strength, and attention.
-
How am I able to reference a specific value of the (brain.getCSV()) just to get the attention or meditation values in the serial output? I want to write if-statements based upon these values. Is there a way to name the specific value in the array or reference it via a number in an arduino sketch to allow me to do if-statements that will tell the arduino to power the forward motor. Can you help?
-
So I was wondering is one single arduino capable of receiving a signal from the EEG (RX pin and GRD) and then on the digital side Pin 2 - Forward, Pin 4 - Backward, 3.3v - To the power TP on the RC controller, and GRD to the Ground. So do I need to use multiple arduinos, or processing or anything or can I use one arduino and my sketch to make it work?
Below is my code I have tried to write I thought it would finally work but no luck, any help you all can provide?
#include <Brain.h>
#define FORWARD 2
#define BACKWARD 4
int MindFlex = 0;
Brain brain(Serial);
void setup() {
Serial.begin(9600);
pinMode(FORWARD, OUTPUT);
pinMode(BACKWARD, OUTPUT);
pinMode(MindFlex, INPUT);
}
void loop() {
int attValue = brain.readAttention();
if (brain.update()) {
Serial.println(brain.readCSV());
delay(2);
}
if (brain.readSignalQuality() == 0) {
Serial.println("Good Connection");
delay(5);
}
if (attValue < 50) {
digitalWrite(FORWARD, LOW);
delay(5);
}
else if (attValue > 50) {
digitalWrite(BACKWARD, LOW);
delay(5);
}
}
Here is an example of the serial output, I am calling it an array I think that’s what it is.
24001,5232,28374,14588,8769,6155,2686
0,40,94,2158540,612203,129669,58072,53379,24860,17169,8943
0,35,83,539645,34005,8947,14976,7326,5302,1689,1147
0,30,66,173791,145539,14610,7782,25125,23536,21001,18331
0,30,43,520130,263998,17963,8589,92736,40831,21627,10849
0,44,44,735608,39219,6620,12921,13447,6531,3570,5797
0,35,38,29141,77058,20896,2770,4403,3690,1782,946
0,20,44,1116069,114167,23296,7537,14569,4666,2677,1915
0,20,50,16987,31509,2457,2867,13629,4929,1050,419
0,4,37,2291927,842580,37290,34925,81330,24469,11039,9710
0,3,23,647256,613229,12266,36502,57075,21455,18017,18053
0,7,20,940493,470588,49443,54791,60543,25691,21935,12380
0,1,35,332324,78103,29726,16857,17505,4001,4255,1080
0,1,54,43427,19858,4641,9234,3382,1190,2175,696
0,1,75,111507,52244,26973,10449,6571,5501,1548,1174
0,8,87,1754380,127393,61628,38826,27425,22277,19257,7166
If you could help me out I would really appreciate it, I have been working on this for over a month scouring the internet for resources and trying different methods and I think I am finally close but just struggling to finish it up. Thank you!