Picture of (w/ Video) Basic Arduino Robot, Light Seeker!
Many times I have Googled for "Arduino Robot" in hopes of finding a robot to build. I end up finding many versions of a obstacle avoiding robot that uses either an infrared or a sonar range finder sensor mounted on a servo to detect objects in its way while randomly roaming the area around it. The problem with this robot is it is expensive and very advanced in some aspects for a "first robot" to make with an Arduino board. The cost of a servo is about $10, and a range finder sensor runs from about $10 - $30.

This instructable will cover how to make a light seeking robot (Photovore), and some robotics and motor control basics. This robot can be built with parts found at the nearest Radio Shack, if you already have an Arduino board and a robotic base. The cost for a five pack of CdS cells (Light dependent resistors) cost $2.99 at Radio Shack. and a 15 pack of NPN transistors (very useful later on) are also $2.99. Of all these parts, we will only need two NPN transistors and two CdS cells.

Please remember, this is my first instructable.
I really appreciate criticism, comments, questions, and suggestions.
Your feedback will help me improve this instructable and future instructables created by me.

Check out our website

Note: by posting any pictures in the comments, you are giving me full rights to the posted image (disclaimer to post robot pictures on the last step.)

If you have a robot base, with and Arduino and full motor controller, you can use it to control your robot with a computer:

evanthebrain7 months ago
Nice robot

sweet sweet banter

Atom 61 year ago

Do you mind posting the full code at the end or something like that.

That would really be helpfull!


Randallcp1 year ago

Can you please tell me where to attach the orange and yellow cables that go under the arduino?? Email me at rcperecman@aol.com. Thanks a lot!!

baiqra1 year ago

what this robot work?

and give information about it.....


baiqra1 year ago

what this robot work?

and give information about it.....


baiqra1 year ago

what this robot work?

and give information about it.....


baiqra1 year ago

what this robot work?

and give information about it.....


baiqra1 year ago

what this robot work?

and give information about it.....


ram_woj1 year ago

what is the alternative of tamiya tracked vehicle chassis?

ishan5531 year ago

please tell me which wire to attach where.

you can mail me at ishanphansalkar@gmail.com

plz inform me.

and dude awesome project

neklausk1 year ago
gimme da code
exia001 year ago
this is my mini project. thanks to Chowmix12 for the coding, I only made some adjustment on the LDR reading, and change where the motors connected to pin because I'm using motor driver.

and on the top of the board I put Xbee to send the reading wirelessly to MatLab and plot some graph.
ecc2061 year ago
Hi, does it crash often?
Halphinian1 year ago
ive got a question does the code on this page work the same for arduino uno?
impressive project. this show us what wonderful robot can be built with a simple light sensor
FLIPminoman2 years ago
If you get lost in a cave it's light seeker to the rescue! +1 for practical application! Or you can use it to find the best spot for a light-requiring plant!
Ah! i've got it working! thank you so much!
arduino 1232 years ago
can you transfer the code on an attiny?
theargha2 years ago
Pls include some pics during assembly
axz12 years ago
Hi.. Can you please give more instructions on the assembling of hardware?
curious062 years ago
Hey great tutorial and im currently building the same thing...i have a problem though...i'm using the tamiya gearbox and instead of npn transistor, im using TIP120. however, after doing all the connection the motor just move a bit and stops. i guess it needs more torque to move forward. could you please help me out or suggest i do something?
rashtekar2 years ago
i am not able to get the aurduino with proto shield.. :-(
what is the name of your robot base, or can you recommend where to buy one online? Instructable is awesome, thanks man.
NinjaCrow3 years ago
Ahh this brings me back, My first robot was surprisingly similar :)

I absolutely adore the Tamiya base. I remember seeing it at Fry's one day and buying it with the express intent to build a robot :)

Never did finish the sensor package I wanted for mine so it just took a range reading on objects in front of it. Then took the last bid from that reading to decide on turning right or left. Always meant to go back and finish it but alas my cat had other plans ...... like puking on it ~.~
something13 years ago
Hello what where the transistors and diodes and resistors for.

And I have a problem i cant get the same readings from both sensors they are very different i tried using 2 5k pots the change the values but they dont work well at all. I was thinking about constraining the values and mapping them to 0 - 255 but i cant figure out a code for that. I am using the LDRs for a Line Follower.
Quick speculation.

The transistors are being used to drive the motors. The Arduino cant source enough power on its own, the transistors are acting essentially like a light switch that the Arduino can flip on and off that connects directly to the power supply.

I'm rusty but the resistors are either acting for biasing or to limit the current, maybe both.

A lot of times you will see both a capacitor and a diode hooked up to a DC motor, the caps help with the initial power draw that the motor can place on your supply.

The diodes are there to prevent reverse power flow from the motors. Motors are act a lot like inductors. primarily because both are essentially wire windings. When you power an inductor it induces a magnetic field. When you stop the power flow to the inductor that field collapses and you are going to get a negative voltage spike.

As for the sensors the question is how different are the readings and are you taking readings under the same conditions? Just to decide if they are working properly you should probably take a multimeter and get a resistance reading. First by covering the sensor then by saturating it with as much light as you can. As long as those readings are similar and within spec for the part then you are fine.

The rest of the time the readings should be different. That is how the robot decides which direction to go.
emdarcher3 years ago
i am making a robot using your instructable, but i am using a base just like in this instructable, http://www.instructables.com/id/RC-Car-to-Robot/.
it is an rc car and is using the arduino motor shield which has an H-bridge.
over serial it appears to work fine, but when driving it's steering wheels keep turning back and forth rapidly and randomly, sometimes stopping a bit in the left turn position.
i don't really know the problem, the left and right turning codes have worled otherwise in non-sensor tests.
i really want this to work, it is my first arduino robot, so i am kinda a noob.
i chose the rc car as a chassis because it was easier to obtain than the tamiya, although i might get that when i have more money.
also i was using the makershield, and now a full sized breadboard to maximize the space between the two sensors but has not helped,

anybody know the problem or how to fix it,

my rc car was also modified to be switched from rc or arduino control, so it still has a rc board within its body, but the motors are connected to both the arduino and rc board. the power is from the on-board battery holder with 4 AA batteries. the power connections are to the Vin and ground screw holes on the arduino motor shield.

any help will be greatly appreciated
You should DEFINATELY add a bluetooth module to this robot... everything is a little more fun when you have an extent of control over a device.
2+2=43 years ago
Great tutorial for beginners- Thanks

How were you able to connect the Protoboard to the motors?

I am currently following this tutorial (in my spare time), and right now I have completed the base, platform, and building the protoboard. What is the next step?

I appreciate any help I can get
rhuk3 years ago
Hi, did you use the gear in standard speed (58:1) or in low speed (203:1)?
Thank you.
jhuang163 years ago
hi could you provide more detail about making the suspension system on the tank? thank you
Would it affect the light sensing ability if I were to put a cover over the top?
singh12343 years ago
hi guys, I want to build a robot like this but instead of any sensors, I want to pre-program a route into an Arduino, so when i turn it on, the robot follows the route I program in Arduino. Can somebody please help me with the program. I dont know where to start. I do know c++. thanks in advance.
A question.... Can an adafruit motor shield be used for this one. Is the circuit design for it the same. The Adafruit Motor Shield is an H Bridge shield used for controlling dc motors, servos and steppers.

http://www.ladyada.net/make/mshield/index.html here it is.
Chowmix12 (author)  DHTArduinoNerd3 years ago
Yes it can! The Adafruit Motor Shield is perfect for this project!
could you post instructions on how to install the components through the adafruit.
Chowmix12 (author)  DHTArduinoNerd3 years ago
I don't have any experience with the adafruit shield, but you should connect the motor leads to the shield, and then you will be able to control the two motors using the specific pins. look for more info on adafruit's website.
Bl1ZzARd73 years ago
Did you have to cut the drive shafts for the dual motor to work on the tamiya Chassis kit? Or is the dual motor compatible to work with the chassis out of the box
Chowmix12 (author)  Bl1ZzARd73 years ago
I didn't have to cut the drive shafts for the Chassis, but i did have to make two notches in the wood Chassis for the mounting screws.
tim1273 years ago
Nice robot, im thinking of making something similar. I have a question though, in the second vodio you plug something into some pins on the robot and it runs wirelessly, what is it and what are the pins?
Chowmix12 (author)  tim1273 years ago
I just noticed my first reply didn't come through.. So! The module I plugged in was a Bluetooth module. It acts just like a serial connection like the one in a USB plug. I suggest getting used to Serial connection and building up your robot to be controlled through the USB cable. Then, when you are ready, you can use a Bluetooth module. The RX of a Bluetooth Module connects to the TX pin (pin 1 on Arduino), The TX pin of the Bluetooth module goes to the RX pin (pin 0 on Arduino) . Make sure that the Bluetooth module operates at TTL levels, which is 5 volts.
Thank you, i have never used bluetooth before to connect to a computer, is there a specific module that you prefer/ Or they all the same if they operate at TLL levels.
hhhh19973 years ago
My motor needs more current what should i do? (2A Per Motor)
Chowmix12 (author)  hhhh19973 years ago
Try a dedicated motor driver.
what do u mean ? i'm new to arduino..
vadipp hhhh19973 years ago
There are separate boards available which can be plugged into the arduino board and control the motors. You can search for "arduino motor shield" on your favourite internet search engine.
vadipp3 years ago
There is a bug in your code:
SensorDifference = abs(SensorRight = SensorLeft);
should have - instead of =, like this:
SensorDifference = abs(SensorRight - SensorLeft);
Maki_mx3 years ago
Thanks!! I have been having problems connecting, the negative terminals and the ground, it just wont work, could you repeat in a different way how to connet the emmiter and the collector? Everything else works fine.
Maki_mx3 years ago
Hey, could you pleace help me out (dummie style) and tell me how to use the bluetooth modem? do I have to change the code? How do I connect the modem to the arduino. Thanks :D
pnova83 years ago
Hey, great I'ble, I was able to follow your instructions easily, but am having one small issue and thought you might be able to help. Only one of my motors, the left one, actually runs. However, both light sensors respond in a logical way; when the right one is covered or the left is exposed to bright light, the motor stops, so both work. I know the right motor works too, because when I switch the outputs, the other motor runs (so that shows the output circuitry works on both sides as well). Perhaps it's something with the inputs? But both light sensors work properly, so I'm not sure it's that either... Anyway, I think you did a great job on this and if you have any ideas I'd really appreciate them!
Chowmix12 (author)  pnova83 years ago
If I understand you correctly, both transistors are working, but you aren't able to use them with a certain pin. You may want to try using a different pin for your motor, incase one pin is defective. You will have to change the code a little bit though. Give it a try..
That was it! It works now. Thanks for the tip, and great I'ble! 5*
i did something like this but with one photoresistor 3 servos 2 continiuos rotation and one not and no transistors
wow good job
Chowmix12 (author)  fatboysoccer4 years ago
Thanks. Vote for me if you liked it. Any suggestions for improvements on this I'ble? It's my first I'ble so I'm not really sure.
no its fine as it is. you got my vote
im using atmega8 ic ,can you guide me how to configure the ic ..just send me the basic requirements to develop a program...and how to configure each port
got my vote too
Chowmix12 (author)  hightekrednek23964 years ago
arunkatrina3 years ago
hi chowmix
it was wonderful to c ur robot
can u give me more details about how to connect the components in bread board
my id is kaifarun@gmail.com
help me friend
SMalvar3 years ago
Hi! First of all, congrats! That's an amazing project. Very instructive... I was thinking if we could somehow put a temperature sensor. So it would be an robot which searchs for fire and warns people about the high temperature (in case it's true).

Is there any possibility you can put a circuit diagram? Or one of those reeeeeeally nice squemes like: http://images.bit-tech.net/content_images/2010/09/arduino-projects-getting-started/arduino-morse-flasher-board-layout-large.jpg ?

I'm still studing so I'm a little confuse about your schematics...

THANK you a lot! =)
Wow. I never thought to use light sensors for an OAWAR. This is the best simple robot I have seen on instructables. I thought w/ video meant it had a camera on it (which it doesn't but would be cool). I will have to make this bot at some point and I might add a camera and a transmitter!
Chowmix12 (author)  KarateLover213 years ago
I have a mini wireless camera, but i haven't been able to hook it up yet. The robot also has bluetooth, so I can use it wirelessly.
showup3 years ago
Nice one. I understand that you used Tamiya tracked vehicle set as the robot base. Can i know which dual motor set do you use in this project to replace the original motor that comes with Tamiya tracked vehicle set? Thanks...
Chowmix12 (author)  showup3 years ago
Dose the wheelbase match? I mean the width of the Tamiya tracked vehicle set and Tamiya - 70097 Twin Motor Gearbox Assembly Set are the same? Thanks.
Chowmix12 (author)  showup3 years ago
Yes, you can use these.
Chowmix12 (author)  showup3 years ago
You can use this one. 
Please, do check out our website. There are more tutorials to come soon. 
ben_k4 years ago
I have tried your transistor motor circuit as well as two transistor H-bridge designs, and I can't get any of them to put out enough current to power the motors with sufficient torque. They all put out the correct voltages, but either the motors don't move, or they take a lot of time to get up to speed. Do you have any ideas why I'm having this problem?
Chowmix12 (author)  ben_k4 years ago
Are you using a a gearbox, or running the motor shaft directly on the wheels? A gearbox is very, very important for torque. hmm.. what transistors are you using? Also, try using an ac to dc adapter of the wall for more current. Just replace the + and - of the battery with the ac adapter leads.
ben_k Chowmix124 years ago
I've tried both gearboxes and plain motors. In both cases, the motors either spin up slowly or don't spin at all, even with no load on them. I'm using PN2222A transistors, and I'm using an ATX psu for power, which can supply 32A @ 5V.
Chowmix12 (author)  ben_k4 years ago
Don't supply to many amps when they're not needed. You only need about .5 amps. Also, what value resistors are you using?
ben_k Chowmix124 years ago
I'm using 1K resistors. I'm fairly sure the power supply is not the problem though. Just because it is rated for up to 32 amps doe not mean it always pushes that much current through the circuit
Chowmix12 (author)  ben_k4 years ago
hmm.. try changing to an h bridge. STMicro offers an l298hn h bridge for sampling.
ben_k Chowmix124 years ago
Thanks for the tip! I just put in an order for a sample.
Chowmix12 (author)  ben_k4 years ago
Any updates on your robot? I'm eager to see your creation.
ben_k Chowmix124 years ago
I'm nearly done with it- I just have programming and testing left to do. It has taken a while, because it is fairly mechanically complex. I'll be sure to post a picture and a link to an instructable once I've finished.

And once again, thanks for directing me to the L298- I ended up using all three I got in the sample for the 5 DC motors on my robot.
Chowmix12 (author)  ben_k4 years ago
Oh wow, you've certainly have had quite some progress. Whats is your robot designed to do? or are you just making a simple platform? I can help you with the programming if you need it.
ben_k Chowmix124 years ago
I've got the programming down- I already know Python really well, so it did not take me long to get used to the Arduino IDE.

The robot is designed to climb trees, so it is much more than a simple platform! It has eight legs (controlled in pairs) and a telescoping spine, which let it climb sort of like a caterpillar.
Chowmix12 (author)  ben_k4 years ago
That is rad! post pictures and videos, I want to see this!
ben_k Chowmix124 years ago
Here are a couple pictures of it. It is now completely finished mechanically and electrically (there were a lot of kinks to work out), and I still have to finish up the programming.
Chowmix12 (author)  ben_k3 years ago
Hey, I saw a video of your robot. Very cool!
shadovz4 years ago
am happy to see my robot here :D
thank u:)

Chowmix12 (author)  shadovz4 years ago
Hi Shadovz. I was wondering if you had made any improvements to your robot.
dmurali shadovz4 years ago
me too :)
massit784 years ago
Very good stuff!

I’m looking for educational purposes a simple exercise to test a PID control.

Do you have any suggestion how to include a PID control code in your program?

PID control reference:

Chowmix12 (author)  massit784 years ago
If I understand correctly, PID is basically controlling an output's speed based on how far away it is from its goal. For this robot, I would start at using PWM for speed control, and use the SensorDifference integer to determine how fast the robot needs to turn towards light.

PID control enables a gradual change reaching the set point (in your case: gradual change in wheel speeds), not only using a simple ON/OFF control.

I found a very interesting tutorial, in particular for the code the chapter “Developing PID algorithm”, page 16:

Chowmix12 (author)  massit784 years ago
Sorry for the late reply. In this case, I would use fuzzy logic, instead of PID. Switch the two motor pins to PWM pins. I use 5 and 6 for my robot. You'll need to find the PWM value that make the robot move at the slowest speed possible without stalling. Then with a little math:

a - Sensor Difference threshold
b - maximum SensorDifference value;
c - slowest possible PWM value
d - 255;

analogWrite((MotorPin), map(SensorDifference, a, b, c,d);
hussam.tech4 years ago
thank you for you work
Chowmix12 (author)  hussam.tech4 years ago
Thank you for your feedback...
please send me the code and circuit i cant find it at all
while you send it check this out!

Chowmix12 (author)  Jordan arduino4 years ago
The code is on the 7th step. The final circuit is the second picture of the 6th step.
shadovz4 years ago
hello sir !!!
it's a great instructable for beginners like me !!1
am nt using tamiya dual gear box instead i use two dc motors and the wheels are coupled directly to the shaft .
i hve one doubt whether the above code suites me.....?!?!?!?
Chowmix12 (author)  shadovz4 years ago
Does your robot move effectively? I'm not sure if you will be able to get enough torque straight off of the motors. Anyway, If you are using transistors, the code will rok, but if you are using an hbridge, you will have to modify the code a little bit.
thank u for the reply!!

Am gonna use the transistors as you mentioned in your i'ble

this is gonna be my first robot and am very much excited about it :)

We need many i'ble from you with DC motors as it's more available in my place:)

Chowmix12 (author)  shadovz4 years ago
Thanks. Rate the instructables if you liked it. If you need any more info just reply or PM me.
Well i did it !!

5.0 best ever :)
Chowmix12 (author)  shadovz4 years ago
Thanks! Post pictures!
hi sir!!
i made the light seeker with h-bridge and modified your code a little bit :)
am very excited to see the robot turn towards the light:)
i made the base of the robot with plastic:)
thank u so much for the great instructable :)
Chowmix12 (author)  shadovz4 years ago
Very nice! I posted your pictures on the last step of this I'ble
thank u :D

tridecagon4 years ago
Third picture looks like a tank.
Electrodude4 years ago
how much would it cost if you bought all the parts?
and would it be possible to add speakers and make it play music?
Chowmix12 (author)  Electrodude4 years ago
Depends on what parts you already have. The arduino costs about $30. a robot base can vary greatly on the price. The transistors will be about $3 and same with the LDRs if you get them from radioshack.

I don't have any experience with playing music on Arduino but i think you should research the Wav shield.
ms104 years ago
verry nice.iliked it
Chowmix12 (author)  ms104 years ago
Thanks. Rate it 5 stars if you think it deserves it.
bigmike554 years ago
I am convinced that this is a truly great project for starters. You have my vote, all thumbs up!
Chowmix12 (author)  bigmike554 years ago
Thank you. Please help me spread the word about this I'ble so that more people can learn from it.
mary candy4 years ago
;) nice
Chowmix12 (author)  mary candy4 years ago
Thank you.
KnexFreek4 years ago
very cool 5*
Chowmix12 (author)  KnexFreek4 years ago
Thank you :)
hey, you did not provide the model number of npn transistor
Chowmix12 (author)  karthik_reddy424 years ago
All you need is an NPN transistor. Common transistors such as the 2N2222 or the 2N3904 will work.
wow that looks extremely similar to the parallax boe bot ????
Chowmix12 (author)  scottyblankinship4 years ago
Many companies use the design of Tamiya's tracked vehicle design. Look at DFRobotShop rover's design, also the same design.
can any one tell me from where i can perches it
and cost of this robot
Chowmix12 (author)  akshay_r_mahajan4 years ago
The cost of this robot varies greatly from where you buy the components.

First i would recommend you either build a robotic base from another Instructable, or buy one. The cost will vary depending on the specifications of the base.

Then you want to purchase the components from a website like digikey or mouser, etc. or you can buy them from a local shop like radioshack.

you can also buy your Arduino from various websites. I bought mine from Adafruit Industries.
wsong4 years ago
ha ha very very good!
Chowmix12 (author)  wsong4 years ago
Thank you so much!
Your code looks very well laid out from what i see. I am mainly a hardware guy , but I crave to learn better coding. When I read through code like you write,I find it easy to follow and thus easy to learn from. I am happy with "It works" never mind "It's efficient!" , bit of a joke there !
Thanks again for your contribution ,
Chowmix12 (author)  Build_it_Bob4 years ago
Thanks again for your feedback. It's nice to have someone in the community read over my work.
Very nice work ! I can't wait to try some of your code !
I think you are doing a great job and look forward to following your instructibles.
Chowmix12 (author)  Build_it_Bob4 years ago
Thanks for the feed back. I realize, my code may not be the most efficient so any suggestions for improvements is gladly appreciated.
AgeingHippy4 years ago
Hi Dude

Thanks - I have learned a few things... especially that I can in fact control motors without a servo driver but by using NPN transistors. Also this led me to look into an H-Bridge, and I see that can be built as well.. probably with 2 transistors and 2 electronic switches (2 more transistors?)

Anyway, I was just wondering why you have the diodes sitting in parrallel with each motor?

(I am a total electronics noob and am learning through others examples...)

Chowmix12 (author)  AgeingHippy4 years ago
Thank you for your awesome feedback.

You will need 4 transistors for one h bridge. Think of it as one NPN transistor for every state of the motor pins. The only possible outputs are HIGH and LOW and two motor pins. Meaning you need to have 4 transistors. Although, I recommend buying a motor driver as it has a little more circuitry so that you can add speed control, less pins to operate, and you have a third possible state to your motors, not connected (High Impedance). This is a little complicated and it took a little while for me to understand so don't worry if your confused.

The diodes are to protect the transistors. Certain properties of inductors (electromagnets inside the motor) cause electricity to be generated and therefor flow back into your transistors. The diodes provide a route with less resistance so that the electricity can flow back to the batteries.

PM me if you have any other questions.
Thanks Dude.

A very clear and concise explanation.

Much appreciated :)
FazJaxton4 years ago
This is an excellent instructable. Fun idea, nice implementation and writeup.
Chowmix12 (author)  FazJaxton4 years ago
Thank you so much!
jekan7774 years ago
D5quar34 years ago
You can make this a lot more simple by using continuous rotation servos like in http://www.instructables.com/id/Build-Bluetooth-Robot-Fast-and-cheap/ and using a code like this one http://letsmakerobots.com/node/2164
Chowmix12 (author)  D5quar34 years ago
This was supposed to be a first time robot build. The first link does provide a good tutorial on how to build a robotic base but it uses servos and i wanted to keep this simple. I'm not a fan of the second link as it uses a steering used by cars on the road today, however, most robotic bases (including the one in the first link) use differential steering.
janw4 years ago
Very nice instructable! And a good way to start robotics.

just try to add your schematics in the right rotation. I needed to tilt my screen to read them ;)

If you want to try range detection, try the IR methode. It is not as expensive as ultrasound. you'll need 2 x IR LED and 2x IR receiver for it but if you look around you can find them all together for about 5 - 10$
Chowmix12 (author)  janw4 years ago
Sorry about that, I got it fixed now. Thanks for the patch. I plan on experimenting with IR detection soon.
There are IR sensitive photoresistors. Perhaps you could use them instead of the visible light sensitive parts.
Chowmix12 (author)  thepelton4 years ago
That would be good for sun tracking. Thanks!
is your arduino modified it looks like a differant power regulator
Chowmix12 (author)  hightekrednek23964 years ago
Good eye! I used this instructable to replace my voltage regulator. http://www.instructables.com/id/Fix-a-fried-Arduino-Mega/
ok cause it didnt look factory
mary candy4 years ago
good luck at the contest ;)
Chowmix12 (author)  mary candy4 years ago
Thank you.
Lindie4 years ago
Chowmix12 (author)  Lindie4 years ago
Thank you!