Author Topic: QRE1113 IR reflectance sensor help  (Read 2698 times)

cityshaker

  • Newbie
  • *
  • Posts: 1
QRE1113 IR reflectance sensor help
« on: March 23, 2013, 05:39:01 pm »
I trying to use a QRE1113 IR reflectance sensor to turn on a led.  I had the code and sensor working with an older Arduino but I can't get it working on the digispark and my head is spinning trying to figure why...  Any suggestions are most welcome...  Here's my code...

int sensorValue = 0;
int ledPin = 0;


void setup() {

pinMode(0, OUTPUT);

//You need not set pin mode for analogRead -
//though if you have set the pin to output and later want to read from it then you need to set //pinMode(0,INPUT);  where 0 is the physical pin number not the analog input number.
//see below for the proper pinMode statement to go with each analog read
}

void loop() {
 

sensorValue = analogRead(0); //read P5
//to set to input: pinMode(5,INPUT);
//THIS IS P5, P5 is Analog Input 0, so when you are using analog read you refer to it as 0


if (sensorValue < 30) 
{digitalWrite(ledPin, HIGH);
delay(1000);
} else {
  digitalWrite(ledPin, LOW);   // turn the ledPin off
}

}