1

What's the best way to wire a QRB1114 IR sensor to an Arduino Uno? I'm attempting to use it as a white-line-on-black-background line detector. Google shows many different ways wire it to an Arduino, but I'm using this one because of its simplicity.

However, when I tested the circuit using the AnalogInput example code, I'm not getting the expected behavior. It registers a reading of 0 for both white and black backgrounds (I'm using white and black electrical tape as test surfaces), and occasionally registers between 5-10 if there's nothing in front of it at all.

What is the most likely problem? Is this circuit an improper way of wiring the sensor? Is my sensor defective? Is the code not reading it properly?

This is my test code:

#define BUTTON_PIN 2
#define LED_PIN 13
const int IR_SENSOR_PIN = A0;
int sensorValue = 0;
void setup() {
 Serial.begin(9600);
 pinMode(LED_PIN, OUTPUT);
}
void loop() {
 sensorValue = analogRead(IR_SENSOR_PIN);
 Serial.println(sensorValue); 
 delay(1000);
}
asked Oct 26, 2014 at 16:24

1 Answer 1

2

It was a dumb programming/wiring problem on my end. As I discovered from this description, the signal pin needs a pullup resistor. Since my circuit doesn't have that, I need to enable the pullup resistor on A0, which I wasn't doing.

After modifying my code to do that, the sensor works as expected.

answered Oct 26, 2014 at 17:02
1
  • Good find. Depending on the range (white vs black surface) you get from analogRead you might want to use a different value (external) resistor. Commented Oct 26, 2014 at 19:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.