IR sensor (emitter and phototransistor) dysfunctional

We've been stuck on this issue for a while now. Basically, we have an IR base pair -- an emitter and a phototransistor -- that is supposed to detect motion. Here is the code.

void setup() {
  Serial.begin(9600);
   pinMode(A3, INPUT);

  pinMode(2, INPUT);

}

void loop() {
  int sensorValue = analogRead(A3); // change A0 to your sensor pin
  Serial.println(sensorValue);
  delay(500);
}

However, everytime we run the code and make changes, numbers on the console display as either only 0 or 1 (from digital) or 1023 (from analog), and are not actually responsive to motion close to the sensor.

We know that the LED emitter is working as we have used our smartphone cameras to detect the infrared light successfully.

Any help is greatly appreciated.

This setup is not supposed to give you the distance. If you want to measure the distance of the nearest obstacle, you have to use a SONAR sensor.

1 Like

Thank you so much for your clarification. We meant motion sensing by infrared radiation, sorry.

It is more helpful to take a picture of a hand drawn wiring diagram carefully labelled. The picture you posted is incomplete and probably misleading.
BTW, who is 'we'

1 Like

That looks like a kit you wired up. what kit? As @LarryD pointed out, your resistor has both ends in the same row of holes (e.g. tied together) so isn't doing anything. Most definitely wired wrong.