Go Down

Topic: Infrared Sensors~Code to make them work? (Read 637 times) previous topic - next topic


Hello everyone,

I'm working a project that involves using infrared sensors and infrared beamers, what i'm trying to do is basically I have the beamers and sensors on a mobile robot,I want the beamers to send out an infrared signal so it bounces off nearby surfaces and returns the signal back at the robot for the sensors to pick up.

Now I know very little about the code needed for the sensors to work but what I do know is that I need to set up code so that my Arduino is constantly monitoring the sensors, the part that i'm turning to you, the community, for help, is the part of code that measures how intense the returning signal is and when it is past a certain level because  I want a certain action to execute once it's past that level.

For example, If the intensity of returning beams is level 50+ I want the board to execute a command.

Please keep in mind that i'm a novice programmer and I rely quite heavily on these forums so if you post suggested lines of code to try to keep it simple so its easier for me to understand, that would be great.

Thanks in advance!  :)


You're going to want to buy a Sharp IR range sensor to do this. It's not a trivial matter to use discrete IR phototransistors and emitters to build an equivalent.

Interfacing these devices is simple; the sensor has connections for power, ground, and one connection goes to an analog pin on the Arduino. An analogRead() of that pin then returns a value between 0 to 1024 which is relative to the distance from the sensor to an object in front of it.


Thank you for the link, it is extremely helpful!

Go Up