DIY Infrared Sensor Module using Arduino
Have you ever wanted to make a line following robot but the infrared sensors were too expensive for you? Do you want to upgrade the robot in my other instructable?
Well this instructable comes in two stages, Stage 1 is the prototyping stage, where you build the circuit on the bread board and debug it for design flaws.
The good thing about this tutorial is you’re able to do many things with these sensors.
Also, if you’re from the UK and have a maplin store near you, you’ll be able to get some IR transmitter and receivers for 99p (They’re side facing LED/phototransistors, so you can have a low-profile sensor module), More on this at the end of the instructable.
1x Bread board
1x Strip board
1x Wire reel, black
1x Wire reel, red
1x Wire reel, green
2x Infrared LED (Maplin/Sparkfun)
2x Phototransistor (Maplin/Sparkfun)
2x Red 5mm LED (Maplin/Sparkfun)
2x 1k Ohm resistor
2x 220 Ohm resistor
Heat shrink tube (Not used)
Heat source (Not used)
Step 1: Let’s Get Started
You want to take your bread board and your infra red LED’s and photo transistors and place them side by side (1 hole apart) in the bread board, repeat for the other infra red pair.
Now let’s start wiring up the infrared LED’s first, place a 220 Ohm resister in the same row as the IR LED cathode then wire it to ground, and make sure to wire both. Next you need to wire up both of the IR LED anodes to the power rail.
Step 2: Keep Going
Now we’re moving onto the photo transistors. Take the red LED’s and place the cathode in the photo transistors anode row, next we place a 1k Ohm resistor inside the photo transistors cathode.
Now we take a wire and connect the anode of the red LED to the power rail. We also need to ground the photo transistors do that now.
Now we just need to wire the photo transistors to the analogue inputs zero and one, to do this wire the cathode of the photo transistor before it goes to the 1k Ohm resistor, the left most wire should go to analogue zero and the one on the right should go to analogue one.
Step 3: It’s Alive, Alive!!!
Now if you wire in the power supply from the Arduino (+5v and Ground) if you wave your hand in front of the IR LED/phototransistor pairs, you should notice the red LED’s fading from dim to bright and back as you move your hand. If the LED’s are indeed facing back and forth congratulations you’ve completed the basic prototype, you can move onto the next step.
How ever, if you’re not getting any results from waving your hand back and forth you must check your wiring (Maybe your IR LED’s are either burned out or put it in backwards).
Step 4: The Code
If you want to test out the circuit, upload the following sketch to your Arduino.
/* Line Following Robot
Demonstrates the use of IR LED’s for a simple line
following robot, if it leaves the black line it will
attempt to locate it.
* Follow the instructable on how to construct it.
This example code is in the public domain.
// Motor Outputs
// Left Motor
int M1B = 11; // Reverse
int M1F = 10; // Forward
// Right Motor
int M2B = 6; // Reverse
int M2F = 5; // Forward
// Motor Speed
int mSpeed = 115;
For more detail: DIY Infrared Sensor Module using Arduino
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
This Post / Project can also be found using search terms:
- IR Sensor and Arduino Circuit Diagram
- connection of ir sensor with arduino circuit diagram
- Diy ir sensor
- diy ir sensor module