Problem using analog PIN
Hi all,
Here are some things that I tried to solve the problem:
I'm working on a project regarding P300 waves, and for this reason I need a precise synchronization between the visual stimulation and the EEG signal. In order to achieve this, I'm using a photoresistor placed close to the screen of my laptop, with which I'd like to detect the change in brightness of a square present on my screen.
The firmware of my OpenBCI 32-bit board is v1. This is what I obtain when I send the initialization command:
OpenBCI V3 16 channel
ADS1299 Device ID: 0x3E
LIS3DH Device IDE: 0x33
$$$
In the code that I uploaded on the board I declared the following variables:
int analogSensor = A7;
short int sensorValue;
then, changed the following lines in the setup function:
OBCI.useAccel = false;
OBCI.useAux = true;
and added these ones in the loop function (inside the if(is_running):
sensorValue = analogRead(analogSensor);
OBCI.auxData[2] = sensorValue;
(I uploaded the complete code here: https://gist.github.com/anonymous/f85b26c376d31f57fcbbf11ca3e9920f)
The problem is that the value of OBCI.auxData[2] doesn't change even if the brightness does, as you can see from the following image: https://postimg.org/image/ysetb8gdd/.
Here are some things that I tried to solve the problem:
- I built the same circuit with an Arduino, by using the same photoresistor, and everything works well (the signal that I obtain is coherent with the change in brightness);
- instead of copying sensorValue in OBCI.auxData[2] I tried to copy in it the value of a counter (0-1023) and I could correctly read it;
- I read the signal of the photoresistor contemporarily with the OpenBCI and with an Arduino, and with the Arduino I could read it correctly, while with the OpenBCI it was not updated.
Does anybody have any idea about how to solve the problem?
Thank you in advance for your help
Davide

Comments
http://docs.openbci.com/Tutorials/06-External_Trigger_32bit_Example
But that's not using analog pin. @yttuncel has a code snippet here using analog, he may chime in,
http://openbci.com/forum/index.php?p=/discussion/comment/5075/#Comment_5075
With the default board firmware I could read only the channels data, I tried to read the analog sensor by disabling the useAccel and writing
board.auxData[0] = analogRead(A7)
but it didn't work.
What I noticed is that the value provided at the first sample is correct, but then it is no longer updated..
Then I tried to the firmware with the analog sensor, but I didn't work due to the problem that you explained me.
I really don't know what to do