Pages: [1]   Go Down
Author Topic: QTR-1RC & Arduino Mega  (Read 1597 times)
0 Members and 1 Guest are viewing this topic.
Garden Grove CA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Hi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 
  { 
    qtr.calibrate(); 
    delay(20); 
  } 
  Serial.begin(9600);
}
void loop()
{
  unsigned int sensors[1]; 
  int EYE = qtr.readLine(sensors);
  //Output to Serial
  Serial.print(sensors[1]);
  Serial.print("   Reflectance ");
  Serial.print("0 (Full Reflectance) to 1000 (no Reflectance)");
  Serial.print("Time Elapsed: ");
  time = millis();
  //prints time since program started
  Serial.println(time);
  // wait a second so as not to send massive amounts of data
  delay(1000);
  Serial.println();
  if (sensors[0] == 0)
 {
   digitalWrite(ledPin, HIGH);
 }
  // Turn off the LED if we have a Low Reflectance.
  else digitalWrite(ledPin, LOW); 
}
Logged

Italy
Offline Offline
Full Member
***
Karma: 3
Posts: 142
jayduino rox
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Juergen

Garden Grove CA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Hi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Italy
Offline Offline
Full Member
***
Karma: 3
Posts: 142
jayduino rox
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Logged

Juergen

Pages: [1]   Go Up
Jump to: