LDR Robot with IR and a Servo

The LDR/IR Robot is designed to seek out light and avoid obstacles. The robot uses the Light Dependent Resistor to seek out light and the Infrared Sensor to detect and avoid objects in its path. The following are instructions with pictures to show exactly how we built our robot. Your robot can be designed the way you desire and in your own order. At the end of this manual you will find some pictures of various robots built with this kit. Use your imagination and make your robot unique. Have fun!

Here is a video of the robot in action!

You will find that not all parts have to be used.


  • 1 x Arduino
  • 1 x Battery Holder
  • 1 x Acrylic Chassis
  • 1 x On/Off Switch
  • 2 x Motor Gearbox and Wheel
  • 1 x Power Jack
  • 3 x LDR
  • 1 x IR Receiver
  • 12 x LED
  • 2 x IR LED
  • 14 x Resistor
  • 1 x Servo
  • 4 x NPN Transistor
  • 1 x Ping Pong Ball
  • 4 x Diode
  • 2 x Screw
  • 1 x Bread Board
  • 2 x Velcro
  • 1 x Straw
  • 1 x Wire Pack

The tools used in this project are:

  • Hot Glue Gun
  • Scissors
  • Small Screwdriver
  • Needle Nose Pliers
  • Wire Stripper
  • Sharpie
  • Electrical Tape
  • Soldering Iron (can be done without)

Step 1: Wiring the Motors

The chassis of the robot is not predetermined, make it how you want, the only rule is to make it awesome!
Find the motor, which is already placed within the yellow gearbox, but can be taken out if you so choose for other projects. Attach a pair of the twisted wires to the motor’s metal tabs by first stripping the ends of the wires and then inserting them through the holes in the tabs. Normally this would be done using a soldering gun however it works well to insert the wire through the hole and firmly clamp the wire around it using needle nose pliers. Be careful not to twist the tab on the motor because it might break. Once it is connected firmly, place a drop of hot glue over it to keep it in place.

<p>hey... how do u run the motors . what is the code for running it ? pls answer asap kindly..plsssss</p>
Hi Tasfia,<br><br>The motor are connected to transistors which are switched by pins 8 and 9 on the Arduino. This can be seen in Step:10<br><br>After you have declared pins 8 and 9 as OUTPUT in void setup()<br>eg. pinMode(8, OUTPUT);<br><br>You can turn the motor on in void loop by digitalWrite(9, HIGH);<br><br>You can turn the motor off by digitalWrite(9, LOW); <br><br>If you are still having trouble after this I would suggest going through:<br><br>https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/<br><br>Goodluck!<br>EG Robotics<br><br>
<p>Hello! Iam tryed to make the same, but is not work. How i can contact with you?</p>
<p>Hi Nursultan,</p><p>You can email me with whatever problems you are having and I can take a look and get back to you! My email is ZyanM@interest-ed.org Looking forward to hearing from you!</p><p>EGRobotics </p>
Sir,,This look pretty good!! <br>My question being,, is the transitor work just as an amplifier to amplify the input signal?? <br>and if i am not wrong then here we are not controlling the speed of motor, right?? <br> can we control its speed using pwm pins(analog o/p)?? <br>and How can we increase the sensitivity of LDR? <br> <br>i would be delighted if 'm acknowledged by your suggestion, SIR!!
Hi Garry, <br> <br>The transistor's works to amplify the Arduino's output to the motors. The Arduino's digital outputs can only do a around 50 mA or something. The transistors use that tiny amount to open a gate to the Arduino's 5V which can do around 500 mA. <br> <br>Yes you are correct, in that we can use analogWrite to control the speed of the motor if you wish to change it. <br> <br>You can change the sensitivity of the LDR by either narrowing the the SensorDifference value or changing the 10K resistor for another value. <br> <br>Goodluck! If you make one we'd love to see it! <br> <br>www.EGRobotics.Com
which diode have u used here
Hi ikochar, <br> <br>I missed your reply, sorry. In case you are still wondering we just used what we had around I believe they are 1N4007. Hope you figured something out by now though. <br> <br>EG Robotics
for step 10, where do i put the 2 diodes?
Hi Topek_25, <br> <br>Sorry for the late reply. Here is a quickly made picture of where the diodes go. The diodes go between the motor leads. This keeps any voltage created by the motor spinning from momentum or any other force from being a nuisance. Good Luck! <br> <br>EG Robotics
it is all fine but which transistor have you used here?
We use 2N2222 transistors. Their only rated at around 600 - 800mA so be sure to use them through the Arduino so that it bogs down the voltage regulator instead of destroying the transistors. Have Fun!
hey i connected everything the way you described and the left wheel rotates while the right wheel doesn't..they have exactly the same kind of set up and connected to the right pins..but if i switched the left motor pin in to the right transistor the left one work, any suggestion?
Hi Curious <br> <br>Do you have the IR and IR Sensor attached? Or just the light seeking part? If you have the IR sensor attached what code are you using and did it work before attaching the IR Sensor? <br> <br>The Right transistor works because you tested plugging the left motor into it. Is that what you are saying? Did you plug the Right motor directly into the power source to ensure connections between wires and motor? If so did the motor work? if it didn't check connections at the motor especially if you used the hot glue method. Double check your diode set up on that motor as well. <br> <br>Let me know if you have any more questions! also post the solution to help others in the future! Also did you buy the kit from us? if not are you using the exact same motors? You can always email us from our sites email for additional help as well! <br> <br>Thanks, <br>EG Robotics
This is great! It's like you read my mind are are a few weeks ahead of me. I have planned this same project almost exactly and just received all my parts. Even the ping ping ball caster, LDR, and IR. Your instructions have cleared up some details I was working out. I was building my son a robot for Christmas. Thank you so much.
Thats great! Have fun with it!
great instructable! I like how you put code in each step of the process. I like your simple design, do you think it's possible to do this with out a microcontroller? have the output from the resistors drive the motors directly?
To have the output from the Light Dependent Resistors Drive the motor directly would not be possible because of the high resistance of the LDR.<br> <br> My battery Box is 6 rechargeable AAA's so thats 1.2V * 6 = 7.2 Volts.<br> My LDR is putting out 1500 Ohms in Normal Light and the motor is 5 ohms. To find the amps add up the ohms = 1505.<br> <br> Amps = Volts/Resistance Amps = 7.2/1505 = .0047 A which isn't enough to move our motors.<br> Also the voltage usage of each Volts = Amps * Resistance<br> Volts = .0047 * 5 = .023 Volts which also isn't enough volts.<br> <br> However if there was such thing as a LDR that was like 5 or 6 Ohms when it was bright and 4 or 3 ohms when it was dark that would probably work. Instead of using a full blown micro-controller you can do like <a href="https://www.instructables.com/member/Higgs+Boson/" rel="nofollow">Higgs Boson</a>&nbsp;did in <a href="https://www.instructables.com/id/Simple-light-seeking-robot-with-555-timing-IC/" rel="nofollow">this Instructable</a>&nbsp;and use a 555 IC. Which you made me want to do now! Maybe I'll add how I did it to mine later! Thanks!
what if you just use a transistor to step up the current but control the voltage with the LDR?
So I set up a circuit like the one below and it worked in a brighter setting. If I had some potentiometers lying around could have played with it a bit more. Lower resistance LDRs would have worked better as well. However I am interested in your opinion, how would you set it up? <br>Thanks! <br>
yes, this is exactly what I was thinking! And yes, the high resistance of the LDRs will make the range of the voltage divider somewhat limited. There is a way to get around this: set up another transistor as an amplifier.<br /> <br /> Start with a circuit like <a href="http://www.circuitstoday.com/wp-content/uploads/2009/09/Integrated-Transistor-Amplifier.jpg">this</a> one.&nbsp; Set up a pot and the LDR as R1 and R2.&nbsp; (You can forget about the capacitor since we are not working with an AC signal).&nbsp; Then use another pot for RC.&nbsp; You will need to mess around with the pots a little to figure out what gives you a signal centered around 2.5V with a good amplitude (ideally extending from 0 and 5V) from Vout.&nbsp; Eventually, you should replace the pot in series with the LDR with a resistor, and you can use the RC pot to adjust sensitivity.&nbsp; Then send Vout to a second transistor set up as an emitter-follower (just like what you have in the image above).&nbsp; Simply connect Vout to the base of this transistor and drive the motor from the emitter.<br /> <br /> let me know how that works!

About This Instructable




More by EGRobotics:Electronic Christmas Tree Ornament Simple Electric Motor Electric Generator Powering LEDs 
Add instructable to: