IR sensors HELP!

Hi there!

I am building and IR line following robot and i wanted to know how i can make the IR sensor only 1s and 0s to the arduino.


When over black line output 1

When over white output 0

Thank you!

Maybe this can help.

Ok sorry.... How do i move my post?

The problem of your post is not the place, but everything else. In the post that I give you (that you should read before post like the title tells) you have this:

Make an informative subject description, not "help me, I'm a noob", nor something in all capitals. Try to avoid saying "urgent". That's your problem, not ours.

Describe your problem in detail.

If it relates to an electronics part (chip or board), give the exact part number and preferably a link to the data sheet.

Describe how you have connected things like switches. Are they wired to ground? Or +5V? Are there pull-up or pull-down resistors? Post a circuit if there is doubt.

Post your complete sketch (program code)! If you don't you waste time while people ask you to do that.

When you post your code put it between [ code ] ... [ /code ] tags. You can do that by hitting the # button above the posting area.

If you get an error, post the error (copy and paste). Not just "I got an error".

With coding problems, if possible post a "minimal" sketch that demonstrates the problem - not hundreds of lines of code.

If you have debugging information in your sketch, post your debugging displays.

Describe what you expected to happen, and what actually happened. Not just "it doesn't work".

If possible, describe what you are really trying to do, not what you think might work. For example "I am trying to turn on an aquarium heater and pump at the same time", not "how do I break out of an interrupt?".

Don't double-post (cross-post). Your question will be noticed. If you post it in multiple places you will just annoy people who might otherwise have answered.

So, my questions are: - what is your code? - what are your connections? - what is your program doing wrong?

Im just asking what IR sensor to use if i just want it to output 1s and 0s....

Like is there such thing as a digital IR sensor?

If so do you know the product name/model?


I do not think you need a digital sensor to do what you want. A regular IR sensor will do just fine. Interface it to Analog ping on the Arduino board and calibrate your code.

The reading you will get when on the black line would be very different for when not on it.

Hi lele_gricc,
I have used a few sensors for line following, you can buy a cheap module from China via eBay, if you don’t mind a 3-4 week wait. Or build your own! I like to use the Vishay TCRT5000L, TCRT1000 or the CNY70, these are small plastic components which include an IR LED usually clear blue or just clear and an IR sensor in a black case to exclude any visible light that might effect it.

These give a digital output which I prefer, with analogue you sometimes have to play around with the value to get it to trigger. See the data sheet for more details, but basicly: LED anode and Transistor collector to 5V+, LED Cathode to GRD via 180-220R resistor, transistor emittor to GRD via 10K resistor, also emittor directly to Arduino input pin, this gives an HIGH for a White/reflection surface and LOW for Black.

Here’s a couple of pic’s showing 2 Chinese modules and my homehade PCB using the TCRT5000L, you can inprove the Chinese one by putting tubing over the LEDs? to make them more directional… This module uses a LM393 comparator to set the trigger, so you can adjust it for distance/light variations.

Hpe it helps, Regards.


Heres the sensor I use for reading RPM.