The QRB1134 is primarily used as a line detecting sensor for line following robots. Here's how it works. If the sensor detects a white surface, the IR light gets reflected, if the sensor moves over a dark surface, IR light gets absorbed.
QRB1134 is an analog sensor, so it connects to one of the analog input pins on the Picaxe. Here's how we are going to test this:
Reading through a bunch of numbers can be daunting. So in this setup, if the sensor detects a light surface (white), an led will light up, if not, the led will be unlit. Also, a graph will be plotted based on the input read. If the graph value is low, the led should light up, if the graph value is high the led should remain un-lit.
Let's hook this up! (Picaxe 28X project board)
Connect analog pin 0 to G via a 0.1uF capacitor
Connect the white wire (collector) from the sensor to pin 0, 10K resistor to V
Connect the blue wire(emitter) to G
Connect the green wire(cathode) to G
Connect the orange wire(anode) to V via a 330ohms resistor
Connect ouput pin 2 to an Led via a 330ohms resistor
Connect the batteries, usb/serial cable to the 28X proto board
The Code.
Key in this, download it to the Picaxe.
symbol range = b1
main:
readadc 0, b1
range = b1
'debug b1
'debug range
if range > 150 then
low 2
endif
if range < 151 then
high 2
endif
for b2 = 0 to range step 10
sertxd("|")
next b2
sertxd (13, 10)
goto main
Run this. Load up the terminal, set the baud rate to 4900. Now bring the sensor close to a white surface, the graph should go low and the led should light up. With a darker surface, the led will switch off and the graph will go high.
This can be hooked up to a servo to build a line following robot.
Led off, graph high. Sensor over a dark surface
Led lit, graph low. Sensor over a light surface.