Hi, I am working on writing a code that uses EOG signals in which if your eyes moves to the left it would code for a dot and if your eyes moves to the right it would code for a dash. So for example, an A would be represented by two dashes (two eye movements to the right). The circuit has already been built so it does properly track left and right eye movement and it has been verified on an oscilloscope. Now I am having trouble integrating the code into the arduino microcontroller. There are three leads: one attached to the forehead(which would go to ground) , one attached to the left side of the head near the left eye, and one attached to the right side of the head near the right eye. It depends on how it is connected but for now a positive peak(max) represents left eye movement and the minimum peak represents right eye movement.
So far I am thinking one lead (the left lead) could be connected to analog pin A0 and the other lead (right lead) could be connected to another analog pin A1. From here I am not sure how to distinguish between a left eye movement and right eye movement in the code. I was thinking of using two if statements shown below:
int EOG_left = analogRead(analogInPin_Left) // store reading from EOG left lead
int EOG_right = analogRead(analogInPin_Right) // store reading from EOG right lead
// Not sure what are range is so far. Let's say our output range is 0-5V and let's say
// left signal is anything from 1.V to 2. V and let's say right signal is from
// 3.0 V to 4.0 V. These values will change for the circuit but placed here arbitrarily to
// write the code
if (EOG_left >= 1.5 && EOG_left <= 2.5) // looking left
{
return '.'; // if voltage signal lies in this range return
}
else if (EOG_right >= 4 && EOG_right <= 4) // looking right
{
return '-'; // if voltage signal lies in this range return a dash
How do I incorporate a time delay so that someone could look left two time in a row so that you would get two dots. And then what if I wanted to output two dots and a dash (so two eye movements to the left and then a right eye movement). Am I correctly interpreting how the inputs would be delivered into the arduino? Any guidance would be appreciated. Thanks!
an A would be represented by two dashes
That would be M. A would be dot-dash.
You will need to describe the electronics and its outputs much more clearly. This does not make sense:
a positive peak(max) represents left eye movement and the minimum peak represents right eye movement.
The Arduino ADC can read only positive voltages, 0-5V on a standard Uno.
Obviously, timing is very important. Use the millis() function to keep track.
Oh yeah I should have been more specific, I just wanted to illustrate roughly what I was doing but yes I would have to be exact with the dots and dashes to represent the correct letters. Ok, so attached is an output image from the circuit onto the oscilloscope. The negative peaks indicate a left eye movement and the positive peak (highest peak on the plot) indicate a right eye movement. I know arduino can't read in negative values so I do need to add a potentiometer to remove the offset but assuming the offset will be removed (because I know how to do this) any ideas on how to proceed with the coding? Thanks.

The way Morse works is that the gaps between the dots and dashes determin how to split up the data stream.
A period of one dot looking straight ahead means that the letter has not finished.
A period of three dots, which is the same as a dash means the letter has finished.
A period of five dots means the word is finished and you should print a space.
As you have left and right looks to generate your dots and dashes maybe a Morse representation is not the best way of encoding the intention.
You started off reading two ADCs and now you are showing us one signal, with positive and negative excursions.
Decide on the external circuitry before worrying about the coding.
Mike has an important point about the spacing.
The proposed method of communication by eye movements seems very laborious, possibly quite disorienting, and requires close attention to detail.
People have been working on this problem for decades or more. What research have you done about modern methods of using eye movements for communication, and if you think this is better, why?
Hello, I am not sure what is meant by two ADCs. So from my understanding it is a continuous signal so if the person is looking straight ahead then on the oscilloscope you don't see any spike because there is no horizontal eye movement detected. Then, when you look to the left , the left lead detects the eye movement and registers it on the oscilloscope as a positive peak in the image provided and then if someone moves their eye to right then a negative peak. So because two different voltage changes are detected at different times that was my reasoning behind connecting one lead to one analog pin and then another lead to another analog pin. So the circuit itself works in detecting left and right eye movement but I'm not sure how to connect this to the arduino microcontroller. So then if I can't directly connect it into two analog pins then what is another alternative?
Well the idea behind this project was to provide it as a means of communication for bedridden patients where eye movement may be the only option available to use to communicate. Yes, I agree there are still flaws/difficulties for letters that require continuous dots or dashes and then with the spacing. One thought was to allow an elapsed time go by until the next character is registered. I personally haven't done a lot of research except for the experience I have learned in a class this year to work with biosignals like ECG,EMG, and EOG but this is the first time using the signal to actually do something with it and not just monitor.
Sorry I just realized an error on my part. So the left and right leads are connected to the first op amp in the circuit and the output is at another op amp at the last part of the stage. So I do not need to use two analog pins, just make a connection between pin 6 at the last op amp and to one analog pin in the arduino microcontroller.
One thought was to allow an elapsed time go by until the next character is registered.
Read reply #3 again for the details.
It is not particularly difficult to locate the positive and negative peaks in the waveform posted in reply #2. Google "peak search algorithm" for ideas.
Grumpy_Mike:
The way Morse works is that the gaps between the dots and dashes determin how to split up the data stream.
A period of one dot looking straight ahead means that the letter has not finished.
A period of three dots, which is the same as a dash means the letter has finished.
A period of five dots means the word is finished and you should print a space.
As you have left and right looks to generate your dots and dashes maybe a Morse representation is not the best way of encoding the intention.
jremington:
Read reply #3 again for the details.
It is not particularly difficult to locate the positive and negative peaks in the waveform posted in reply #2. Google "peak search algorithm" for ideas.
Ok, thanks I'll look at reply #3 again to help guide how to account for how Morse code works and will look up "peak search algorithm". Thanks again!
Ca you detect a down and up look as well as a left / right movement. That will make things simpler. I don’t think Morse is the right way to go about this. The normal way is to navigate through a matrix of letters or words, but you still have the problem of selection once you have navigated to the right place.
Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
It will be easier than trying to describe your circuit.
Tom... 
jrojas21:
Hello, I am not sure what is meant by two ADCs. So from my understanding it is a continuous signal so if the person is looking straight ahead then on the oscilloscope you don't see any spike because there is no horizontal eye movement detected.
Brush up on your physiology a bit. There is ALWAYS eye movement. Otherwise the image your brain makes will fade. But the peak your looking for will be far above the noise signal.
Paul