loading
Picture of (w/ Video) Basic Arduino Robot, Light Seeker!
P1060967.JPG
P1060981.JPG
P1060969.JPG
P1060972.JPG
P1060976.JPG
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:

 
 
Remove these adsRemove these ads by Signing Up

Step 1: Materials

Picture of Materials
P1060970.JPG
P1060989.JPG
The materials you need are:
2 CdS cells
2 NPN transistors
2 current limiting resistors for the transistors (I used 1k ohm (brn - blk - red) )
2 flyback diodes. (1n4001 - 1n4003). You can scavenge these out of AC to DC converters. (shown in the third picture)
1 Arduino development board (I used a duemilinove, but an Uno, diecimila, NG, etc. will work.)
1 robot base. (Go to step 2 for more info if you don't already have one)
1 Arduino supply battery pack (usually 9 volt batteries.)
1 Motor supply battery (2-4 AA batteries work well.)

Step 2: Robot Base

Picture of Robot Base
P1060976.JPG
P1060969.JPG
P1070013.JPG
P1060996.JPG
There isn't much to say here. A lot of different robotic bases have been shown on Instructables and on various other websites. The main parts of a robotic base is 2 motors, corresponding gearboxes, supply battery pack, a base platform, and an H bridge* 


I used the Tamiya tracked vehicle set, as it was very common, and included many of these things. The tracked vehicle set included a rectangular wooden base, wheels and drive sprockets, tank treads, and a single gearbox (useless for this I'ble, but useful later on). Separately, I had to buy a battery pack and a dual gearbox which included two DC motors.

I made a second layer on top of the Robot Base to hold the Arduino board away from any EMI produced by the motors and possibly interfering with the code running on the Arduino. This is also the reason for having two seperate power supplies for the Arduino and motors.


*Note the H-bridge isn't used in this I'ble. You can find plenty more info on Instructables or Google.

Step 3: Incorporating Light sensors

Picture of Incorporating Light sensors
Debug Screen2.jpg
Schematic(Light Sensor).jpg
The light sensors are CdS cells which are used to detect light brightness. The two leads change resistance based on the amount of light received. Using the sensor requires what's called a voltage divider. One pin of the LDR is connected to ground. The other is connected to the analog input pin and a pullup resistor is connected to the same analog input pin and +5v. Luckily, Arduino has a pullup resistor built in to every pin. To use the pullup resistor, you must first define the pin as an input, then use digitalWrite() to set the pin HIGH like so:

void setup() {
pinMode("analog pin", INPUT);
digitalWrite("analog pin", HIGH);
}

This way, all you need to do is connect one pin of the LDR to the analog input pin, and the other pin to ground.

Using this code, you can read the values of the two light sensors and then display them through the serial monitor. This is the first part of the robot. Later on, we will use the values of the light sensor to control motors accordingly.

The physical setup is simple. Connect one pin of both light sensors to ground, The other two pins two analog input 1 and 2.

Analog pin 1 is for the Right sensor, Analog input 2 is for the Left sensor.

// Copy code from this point on:


/****************************************************************************************************************
 * Program for reading two LDRs
 * created by: Anuj
 * (c)copyright
 *
 *
 * Physical setup:
 * Two LDRs connected to ground and Analog pin 1(Right) and Analog pin 2(left)
 *
*
******************************************************************************************************************/
// Using Arduino Duemilinove

// Pin definitions - attaches a variable to a pin.
const int RightMotor = 2; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 3; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 1; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 2; // This pin is used to read the value of the Left Sensor.

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch
int SensorDifference; // This value is used to determine the difference between the Left and Right

// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.

void setup() {

pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
digitalWrite(A2, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nReading Light sensors."); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop() {
SensorLeft = analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.
SensorRight = analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.

// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.
// This is known as debugging.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\n"); // Prints a new line after all the necessary data is displayed.
}

Step 4: Incorporating Light sensors Part 2

Picture of Incorporating Light sensors Part 2
Schematic(Light Sensor).jpg
After waving your hands in front of the light sensors and watching them change in value, you'll notice when the light sensor detects less light, the Sensor value will be rise, and when it detects more light, the Sensor value will drop. This is because the Sensor decreases in resistance when it detects a bright light. When there is less resistance to across the LDR's two leads, the Analog input pin will start to read a ground signal, or something close to it. When the the LDR is receiving less light, the resistance to ground will increase, and more electricity will flow to the Analog pin from the pullup resistor which is connected to +5v.

By personal preference, I like to have the analogRead() function return 0(min) if the light sensor is dark, and 1023(max) if it detects bright light. We can solve this problem using the software. There are no changes in the circuit.

At this section of code:

SensorLeft = analogRead(LeftSensor);
delay(1);

We can add :

SensorLeft = 1023 -  analogRead(LeftSensor);
delay(1);


This will subtract whatever value the analogRead() function returns by 1023(which is the max value it can return.)
This way, it will invert what ever value the analogRead() returns.
For example, if the analogRead() value is x

x = 0
Sensor value = 1023 - x
Sensor value = 1023 - 0
Sensor value = 1023

x = 1023
Sensor value = 1023 - x
Sensor value = 1023 - 1023
Sensor value =  0


This method can be used to invert any value, as long as you know the maximum value it will return.
For example, if a sensor returns a maximum of 255:
val = 255 - sensor value

Upload this code to the Arduino board and test it out.


// Copy code from this point on:



/****************************************************************************************************************
 * Program for reading two LDRs
 * created by: Anuj
 * (c)copyright
 *
 *
 * Physical setup:
 * Two LDRs connected to ground and Analog pin 1(Right) and Analog pin 2(left)
 *
*
******************************************************************************************************************/
// Using Arduino Duemilinove

// Pin definitions - attaches a variable to a pin.
const int RightMotor = 2; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 3; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 1; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 2; // This pin is used to read the value of the Left Sensor.

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch

// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.

void setup() {

pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
digitalWrite(A2, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nReading Light sensors."); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop() {
SensorLeft = analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.
SensorRight = analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.

// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.
// This is known as debugging.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\n"); // Prints a new line after all the necessary data is displayed.
}




//Do not copy anything beyond this point.




Now we have to sensors to use with our robot, but we're not quite done yet. We need a way to compare these values. Using only these values, we can determine whether one sensor is reading a greater or lesser value then the other sensor, or if they are exactly the same.

Now, because of many other factors such as minor discrepancies in LDR manufacturing, jitter, EMI, etc, the values for the light sensor will seldom be exactly the same. So instead, we can use another integer to determine if they are approximately the same. We can achieve this by using calculating the difference between the two light sensors. We can subtract the value of one sensor by the value of the other sensor and then finding the absolute value of the sensor. This will return the difference of the two sensors and we can either use that immediately, or save it to another integer, in case we need to use it more than once. The final value can be used to determine if the sensors are reading two distinct values, or if they are somewhat similar. The higher the value, the higher the difference. Using an if statement, I can say, if the sensors values are within 100 increments of each other, do this.

if(SensorDifference <= 100)  {
// Execute this.
}


Piggybacking off our previous code that should be still be running on the Arduino board,
we can use the two integers that contain the value of the Sensors to calculcate the difference and save it to a new integer.

The new code looks like this. The changes are in bold text.


/****************************************************************************************************************
 * Program for reading two LDRs
 * created by: Anuj
 * (c)copyright
 *
 *
 * Physical setup:
 * Two LDRs connected to ground and Analog pin 1(Right) and Analog pin 2(left)
 *
*
******************************************************************************************************************/
// Using Arduino Duemilinove

// Pin definitions - attaches a variable to a pin.
const int RightMotor = 2; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 3; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 1; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 2; // This pin is used to read the value of the Left Sensor.

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch
int SensorDifference; // This value is used to determine the difference between the Left and Right

// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.

void setup() {

pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
digitalWrite(A2, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nReading Light sensors."); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop() {
SensorLeft = analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.
SensorRight = analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1); // the delay allows the Analog to Digital converter IC to recover for the next reading.

SensorDifference = abs(SensorRight = SensorLeft);

// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.
// This is known as debugging.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Sensor Difference = "); // Prints the text inside the quotes.
Serial.print(SensorDifference);
Serial.print("\n"); // Prints a new line after all the necessary data is displayed.
}

Step 5: Interpreting Data

Picture of Interpreting Data
Right.jpg
Left.jpg
At this point, we have data from our light sensors and we want to be able to execute functions based on these values.

We have three different data values, Left Sensor, Right Sensor, and Sensor Difference.
Our robot will have the ability to go forward, left, or right based on this data. Lets break it down:


If the difference of the Left Sensor and the Right sensor is under a certain threshold, go straight. This threshold value will be customizable. For this we will add this code within the void loop of the LDR implementation code, after the code has reported the values of the Sensors.

if(SensorDifference <= 75)  {
// Go straight
}

We will add the motor function to go straight in the next step. This step is purely for algorithm. This also applies to the next two sections for going left and right.

If the Right sensor detects more light than the Left, turn Right. Note, that while one sensor reads more than the other sensor, they might still be very close to each other. In this case both functions will be executed. To solve this problem, we can use an else if statement instead. This will only execute only if any if statements before this statement is not executed.

else if (RightSensor > Left sensor) {
// Turn Right
}

Similarly for the Left command

else if (LeftSensor > RightSensor) {
// Turn Left
}

In each of these three commands, we will add the actual motor control, which will be done by writing either HIGH or LOW to the digital pins 2 and 3. We will also add a debug line which will state which direction the robot wants to move. This is helpful for determining if the code is working properly, without having a robot freak out and possibly breaking itself in case the code is not working properly. I recomend running your code on your robot without the motors attached and checking the Serial Monitor to check if things are working properly. If they are, you can proceed to run the code with the motors. 

Step 6: Finally! Motor Control!

Picture of Finally! Motor Control!
Schematic.jpg
P1060996.JPG
At last, We can now control our motors accordingly to the algorithm in the previous step.
Using digitalWrite(), we can switch the transistors on and off by turning the corresponding pin HIGH or LOW.
This will only switch the motor on and off in one direction. We will need an H-bridge to have full control of a motor.
We won't be using an H-Bridge in this Insctructable.

Connect one end of a 1k ohm resistor to pin 2 (right motor) . Connect the other end to an empty row on the breadboard. To add the transistor, align the base terminal of the transistor with the end of the resistor and insert it in the same row of the resistor. Connect the collector to one pin of the right motor. Connect the emitter (remaining pin) to ground. Connect the other pin of the motor to the positive terminal of the battery. Repeat for the Left motor on pin 3. Also, connect the negative terminal of the battery pack to the ground pin on the Arduino.

Here are the functions to get your robot moving.

Straight:
digitalWrite(RightMotor, HIGH);
digitalWrite(LeftMotor, HIGH);


Left:
digitalWrite(RightMotor, HIGH);
digitalWrite(LeftMotor, LOW);

Right:
digitalWrite(RightMotor, LOW);
digitalWrite(LeftMotor, HIGH);

Notice to turn, you must turn the opposite motor on.

Step 7: Final Code

Picture of Final Code
/****************************************************************************************************************
 * Program for a simple light Seeking Robot.
 * created by: Anuj
 * (c)copyright
 *
 * Robotic base should include differential drive.
 *
 * Physical setup:
 * Two LDRs connected to ground and Analog pin 1(Right) and Analog pin 2(left)
 * base of NPN Transistors on pins 11(right) and 12(left).
 *
*
******************************************************************************************************************/
// Using Arduino Duemilinove

// Pin definitions - attaches a variable to a pin.
const int RightMotor = 2; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 3; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 1; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 2; // This pin is used to read the value of the Left Sensor.

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch
int SensorDifference; // This value is used to determine the difference between the Left and Right

// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.

void setup() {

pinMode(LeftMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(RightMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
digitalWrite(A2, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nBeginning Light Seeking Behavior"); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop() {
SensorLeft = 1023 - analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorRight = 1023 - analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorDifference = abs(SensorLeft - SensorRight); // This calculates the difference between the two sensors and then saves it to an integer.

// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\t"); // Prints a tab (space).


// This section of the sketch is what actually interperets the data and then runs the motors accordingly.

if (SensorLeft > SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads more light than the Right Sensor, Do this:
digitalWrite(RightMotor, HIGH); // This is used to turn Left. Notice the
digitalWrite(LeftMotor, LOW); // opposite motor runs to turn Left.
Serial.println("Left"); // This prints Left when the robot would actually turn Left.
}

if (SensorLeft < SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads less light than the Right Sensor, Do this:
digitalWrite(RightMotor, LOW); // This is used to turn Right. Notice the
digitalWrite(LeftMotor, HIGH); // opposite motor runs to turn Right.
Serial.println("Right"); // This prints Right when the robot would actually turn Right.
}

else if (SensorDifference < 75) { // This is interpreted as if the difference between the two sensors is under 125 (Experiment to suit our sensors), Do this:
digitalWrite(RightMotor, HIGH); // This is used to go straight. Notice
digitalWrite(LeftMotor, HIGH); // both motors are enabled to go forward.
Serial.println("Forward"); // This prints Forward when the robot would actually go forward.
}
Serial.print("\n");

Step 8: Now its your turn!

Picture of Now its your turn!
photo.JPG
P1040470.JPG
FXJER0MGOFFXMBL.MEDIUM.jpg
Make your own variants of this robot and post pictures of them below in the comments. I posted pictures of an earlier version of this robot. I'll post pictures of your robot on this page along with my pictures.
1-40 of 148Next »
evanthebrain6 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!

Thanks!

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.....

please.................................

baiqra1 year ago

what this robot work?

and give information about it.....

please.................................

baiqra1 year ago

what this robot work?

and give information about it.....

please.................................

baiqra1 year ago

what this robot work?

and give information about it.....

please.................................

baiqra1 year ago

what this robot work?

and give information about it.....

please.................................

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.
IMG_20131215_203723[1].jpg
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.
1-40 of 148Next »