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.
-
How am I able to reference a specific value of the *char 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);
}
}
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!