The figures above shows the basic idea of any robot, where we have some inputs and output devices connected to the brain and some outputs controlled by the brain. In our case we will have the Arduino like the brain.
The central Brain, controls all movements of the Robot. The sensors will do the monitoring where the light focus is and finally the motors that gives to the robot its movements to go forward, to turn left and to turn right.
The input devices will be LDRs (Light Dependent Resistor) those components have its resistance changed according to the incidence of light on the device. Basically, if there is no incident light, the LDR will have a high resistance (from 200KΩ to 5MΩ more or less), and when the incidence of light the LDR will have a reduced resistance (since some dozens of ohms to rough a few hundreds) as we can see in the LDR's characteristic curve above
A LDR is also sensitive to the wavelength of the incident light, so we can say that it depends on the color of the light.
Step 1: Basic Circuit
In the figure above, we can see the basic circuit for driving an LED using a LDR as light sensor.
In the circuit on the left, initially we can note that the LED is off because the resistance of the LDR without incident light, let the transistor in cut state. When we line up the light focus on the LDR, it will decrease its resistance and thus we have a base polarization, and so the transistor enter in the conducting state, switching the LED on.
In the circuit on the right, we will notice that the LED is initially in the state on, since we have no incident light on the LDR and the LDR have a resistance greater than the sum of resistances of the resistor of 10K + the 10K potentiometer; the transistor base will be polarized driving the LED, and when the light falls on the LDR, the LDR will have a decrease in current and will sustain the transistor into the cut state switching the LED off.
A sensitivity setting in the system is allowed through the 10K potentiometer.
Naturally, we can use the LDR in another way, but this is the most usual form.
Step 2: BUGBot Basics
The robot has two LDR sensors in order to determine if he should move to the right, left, forward, or remain stationary.
1 x LDR sensor RIGHT
1 x LDR sensor LEFT
In our BUGBot, we use DC motors to control transmission system (gearbox and wheels) so that the robot can move and so follow the incident light on the sensors.
It was used the Tamyia GearBox in the ratio 58:1
If the left LDR has incident light, the right DC motor must be turned on to the robot rotate or move to the left.
If the right LDR has incident light, the left DC motor must be turned on to the robot rotate or move to the right.
If both LDRs have incident light both DC motors must be turned on to the robot move forward.
If both LDRs have no incident light, bot DC motors must be turned off to the robot remain stationary.
It is not sufficient only to detect the presence of light on the sensors and drive the motors on/off, the motors must also keep powered by an amount of time for minimum operation.
The control devices LDR sensors and motors, will be done with the Arduino software to run exactly the steps above.
For the motor driver (as they must rotate only in one direction), it is not necessary to use an H-bridge, we can do the motor driver using only Darlington transistors.
Step 3: Schematic and Board Layout
2 x transistors, TIP120
2 x 1N4001 Diodes
2 x 3mm green LEDs
2 x LDRs
2 x 1KΩ resistors
2 x 470Ω resistors
2 x 100 nF capacitors
2 x 5KΩ trim-pot
1 x 2-pin AK300 connectors
2 x2 pinhead
1 x6 pinhead
1 x battery pack (9V or 12V)
The 1N4001 diodes and 100nF capacitors are for circuit protection and noise suppression.
We have green LEDs to indicate whether a motor is activated or not (care with the resistor value, if you use a voltage greater than 6V. I advise you to use 6V/270Ω, 9V / 470Ω, 12/680Ω.
JP2 is the output to the right DC motor and JP3 is output to the left DC motor.
JP1 is the connection with the arduino, as below
Pin 1 => LDR sensor - left;
pin 2 => LDR sensor - right;
pin 3 => logical power, to the sensors (+5V from Arduino);
Pin 4 => common negative from Arduino and DC motors power stage;
pin 5 => command to drive the left DC motor (comes from arduino);
pin 6 => command to drive the right DC motor (comes from arduino).
Later we will make a parallel between the Arduino and JP1's pins.
We saw that the sensors are using the arduino power supply directly.
When we have incident light on the LDR, we have 0V on Arduino pin and when we do not have incident light on the LDR, we have 5V on the Arduino pin (it is the reverse logic used to control the DC motors).
Done through the 5KΩ trim-pots, in this way we can adjust the light level in which we want that the BUGBot answer and run the DC motors for its movement.
Below the original files in Eagle:
Connecting to the Arduino:
Left LDR => A0
Right LDR => A1
Left DC motor => 8
Right DC motor => 9
Connections between the Arduino and JP1 connector:
ARDUINO to JP1-x
A0 - JP1-1
A1 - JP1-2
+5 V - JP1-3
GND - JP1-4
D8 - JP1-5
D9 - JP1-6
Step 4: Software and Programming
Above you have the didactic flows to the software programming.
You can do the download the first version of the Arduino sketch to the IDE 0023 from: http://www.4shared.com/file/3FtFRaAS/Bug_Bot_R1.html
During final testing, I had a small problem:
Due to the motor rotation and gearbox ratio 58:1, the motors was set with great force, so that the BUGBot rotated become very fast and with great strength, losing a bit of light guidance.
To solve this problem, a modification was necessary in the main program the Arduino.
Instead of using digital output (0V and 5V) to control the motor drive, I used the PWM output.
Thus it was possible to control the drive speed of the motor, thereby adjusting the motor rotation and so the driving force of the set.
Below you have the BUGBot version 2.
Get all files needed to build the project at GitHub: https://github.com/Arduinobymyself/LINUSBot.git
Sorry, These videos are in Portuguese, I do not had enough time to translate them.
Step 5: Chassis, Project and Construction
This is the chassis design with all dimensions.
Drilling is up to you, it depends the type of gearbox used and and appearance that you want to give your Robot.
Dimensions in millimeters (mm).
The height between the upper and lower chassis is at the discretion of your design and esthetics of the robot.
Above we have the construction process in acrylic and below more information about it (about 4 hours of work).
1 x Tamyia gearbox kit
2 x rubberized wheels for Tamyia gearbox kit;
360 degrees small wheel or ball caster;
Acrylic plate 300 x 300 x 3 mm
4 x 5mm x 50mm screws + nut + washer;
6 x 3mm x 15mm screws;
15cm transparent tube (5mm) "the spacer";
rasp - round, flat...;
stylet to acrylic cut;
and so on.
Overall Length = 210mm
Overall width = 110mm
Overall height = 48mm
Step 6: Videos
I think this video is not good as I want, but show us the basic concepts and the BUGBot doing its work.
Visit my blog: http://arduinobymyself.blogspot.com.br
that's all folks! I hope you enjoyed and see you in the next project.