So I'm trying to use a short range IR Proximity Sensor as part of a feedback loop for a robotic hand project I'm working on.
I've used google to the point where I have a code, I believe its wired correctly, and I have an output printing in the serial monitor. My problem is that regardless of placing an object infront of the sensor, the output is always 1.
The code I'm using is as follows;
int IRSensor = 1;
int IREmitter = 2;
int ProxReading = 0;
My sensor has 4 pins, which the datasheet says are collector, emitter, anode and cathode from 1 to 4. I'm sure there's an obvious error in my code, but this is all quite new to me and google has if anything left me more confused.
So the digitalRead just goes back to an output of 1 regardless, so must be an analog sensor? The QRE1113 codes I've found seem to have the same problems only with a higher frequency of readings...
You haven't said how it's wired though. I'd go collector to digital pin with input pullup, emitter to ground. Transistor will conduct when there's a reflection, and take pin low. Look for a low to indicate presence of object.