Go Down

Topic: QTR-1RC & Arduino Mega (Read 2038 times) previous topic - next topic


Hi, I'm trying to design a Lucid Dreaming Machine, that detects Rapid Eye Movements. During sleep, your brain is active, and while your sleeping, your eyes are moving while the rest of the body is paralyzed. So i was thinking of a machine that can use infrared sensors such as the QTR-1RC,
Can i use the reflectance to count 20 movements??? Or some sort of difference between 2 sensors??
Here's my code so far.. How would i go for this sort of sketch??? Any ideas are welcome. I picked the QTR-1RC to avoid a ADC

#include <PololuQTRSensors.h>

// Six Analog Pins can be commonly referenced as:
// analog 0 - Reference as: Pin 14
// analog 1 - Reference as: Pin 15
// analog 2 - Reference as: Pin 16
// analog 3 - Reference as: Pin 17
// analog 4 - Reference as: Pin 18
// analog 5 - Reference as: Pin 19

unsigned long time;
int ledPin = 10;

PololuQTRSensorsRC qtr((unsigned char[]) {3},1);

void setup()
  pinMode(ledPin, OUTPUT);
  // then start calibration phase and move the sensors over both 
  // reflectance extremes they will encounter in your application: 
  int i; 
  for (i = 0; i < 250; i++)  // make the calibration take about 5 seconds 
void loop()
  unsigned int sensors[1]; 
  int EYE = qtr.readLine(sensors);
  //Output to Serial
  Serial.print("   Reflectance ");
  Serial.print("0 (Full Reflectance) to 1000 (no Reflectance)");
  Serial.print("Time Elapsed: ");
  time = millis();
  //prints time since program started
  // wait a second so as not to send massive amounts of data
  if (sensors[0] == 0)
   digitalWrite(ledPin, HIGH);
  // Turn off the LED if we have a Low Reflectance.
  else digitalWrite(ledPin, LOW); 


I picked the QTR-1RC to avoid a ADC

A question how far away from the eye do you want to put the sensor? The distance limits very much what you should actually use.
For myself i use HOA1405 sensors to detect rapid wire vibrations/resonance (from 40Hz to 1500Khz), the distance is like 5 to 10mm (using ADC though).


Well that sensor is going to be placed on a sleeping mask. the distance is in mm so i would say off the top of my head as if your wearing glasses if that makes any sense.


Well that sensor is going to be placed on a sleeping mask. the distance is in mm so i would say off the top of my head as if your wearing glasses if that makes any sense

Ok, that is a good distance. In any case I would go with an ADC version of a reflective sensor as it will be probably easier to calibrate (auto calibration in absence of different values during a longer period) and trigger the event. Or even to record the signal the whole time and do a post analysis.

Maybe you should also consider to make the IR Diode tunable with a potentiometer (not with PWM as that would interfere with the recording) so while the person is wearing the mask you tune the Diode that you receive a medium value in the photo transistor.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131