Arduino Bot - Chae-Hee, Franco, Julia
by PHS_Engineering in Circuits > Arduino
196 Views, 1 Favorites, 0 Comments
Arduino Bot - Chae-Hee, Franco, Julia
This project connects a robot to the Arduino. If the robot senses motion it will towards that direction, and if it sense no motion it will stop/not move. To do this, use a set of motion sensors to sense the motion, also you will need to construct a base with a set vex motors and wheels to allow your robot to move.
Supplies
8 wires
2 vex motors
Arduino uno
USB cable
9V Battery
9V Battery Snap Connector
Adruino Breadboard
7 Metal beams (2 long 5 short)
Screws of varying lengths
Robot/object
4 wheels
6 gears
6 axels
12 bearing flats
12 shaft collars
L293NE Driver IC
Ultrasonic sensor
Male to Female Jumper wire
LEDs
Dismantle the Body From the Base
Take Ms. Atkins and gently place her on a table. Remove all the screws connecting her body to the rolling metal base. Discard the original base and store the body somewhere for future use.
Create the Base
Start by getting two long metal pieces and two short ones. They should have an "L" shape from the side. Using one nut and screw on each corner, attach the pieces together to form a rectangle (should resemble a picture frame). After the frame is put together, attach the axels to each wheel, and put the gear on top. Using the remaining two gears and axels, attach them the same way as the wheels. Next, take the six black bearing flats, and line up the middle hole with the small indentations on the short sides of the frame. Secure these in place using a nut and a screw on each side. Take the two axels with only gears and insert each on either side of the frame in the middle opening. Put each of the wheels in the outer four openings the same way.
Attach Vex Motors
Using two pieces, the same length as the short legs of the frame, and a nut and screw for each end, secure the pieces parallel to the short sides. Be sure that both additional pieces are equidistant to the original sides. Using another bearing flat and a pair of nuts and screws, mirror the corner bearing flats (see picture). Ensure the axels have enough room for a shaft collar on each side of the wheel axels. Take another bearing flat, and one screw and nut. Secure the bearing flat to the metal with the screw and nut, on only the right side of the bearing flat. The middle hole will allow the axel to reach and attach to the motor. Secure the remaining left hole to the motor using another screw. Repeat these steps on the remaining motor. Finally, secure each axel in its final position using a shaft collar on each side.
Wire the Circuit
When you start building the breadboard, you need to make sure that the L293D is the right way around. The small hole should face the left top of the breadboard. Connect the L293D to the ground and then put in three wires that connect to pin 11, 10, and 9 into the top two pins of the L293D. Put a wire connecting the 5V into the ground and another wire into the arduino board. Put male-to-female wires on the end of the motors and connect the red wire to the 2nd pin of the L293D and the black wire to the 4th pin of the L293D. Then connect 4 male-to-female wires to the super sonic sensor and connect the ground and 5V to the arduino and the trig wire to pin 4 and the echo wire to pin 5.
Write the Code
int forward = 10;
int on = 11;
int backward = 9;
int trigger = 4;
int echo = 5;
int duration = 0;
int distance = 0;
void setup() { // put your setup code here, to run once:
pinMode (forward, OUTPUT);
pinMode (on, OUTPUT);
pinMode (backward, OUTPUT);
pinMode (13, OUTPUT);
pinMode (trigger, OUTPUT);
pinMode (echo, INPUT);
Serial.begin (9600); }
void loop() { // put your main code here, to run repeatedly:
digitalWrite (on, HIGH);
digitalWrite (trigger, HIGH);
delay (100);
digitalWrite (trigger, LOW );
duration = pulseIn (echo, HIGH);
distance = (duration/2)/28.5; Serial.println(distance);
if (distance <70 ){
digitalWrite(forward, HIGH);
digitalWrite(backward, LOW);
delay (1500);
digitalWrite(forward, LOW);
digitalWrite(backward, HIGH);
delay (1500);
}
else {
digitalWrite (forward, LOW);
digitalWrite (backward, LOW);
}
}
Connect Robot to the Base
Finally attach the Robot to the base, and place it into a doorway.