Many beginners the inhabitants of our site start learning arduino with the creation of simple robots. Today I will talk about the simplest robot on the arduino uno, which like a dog will follow your hand or any other object that reflects infrared light. Also this robot amuse the kids. My 3 year old nephew was willingly playing with a robot :)
I'll start by listing the details that will be needed during the construction - Arduino UNO;
-infrared range finders;
3-volt engines with gears and wheels;
-connectors for 3A batteries;
-battery (if there are not enough batteries);
-Relays to control engines;
Well, and other materials that will be needed during the creation process.
First we make the foundation. I decided to make it out of wood. I sawed a wooden board in such a way that the motors in the slots fit perfectly
Then with a wooden strip I clamp the motors, screwing this strip
Next, on the case, I placed arduino, relays, Bradboard, rangefinders, and under the base of the chassis turning
Now we connect everything according to the scheme
At the end, load the following sketch into arduino:
const int R = 13; // pins to which IR rangefinders are connected
const int L = 12;
int motorL = 9; // pins to which the relay is connected
int motorR = 11;
int buttonState = 0;
void setup () {
pinMode (R, INPUT);
pinMode (L, INPUT);
pinMode (motorR, OUTPUT);
pinMode (motorL, OUTPUT);
}
void loop () {
{
buttonState = digitalRead (L);
if (buttonState == HIGH) {
digitalWrite (motorR, HIGH);
} else {
digitalWrite (motorR, LOW);
}
}
{{
buttonState = digitalRead (R);
if (buttonState == HIGH) {
digitalWrite (motorL, HIGH);
} else {
digitalWrite (motorL, LOW);
}
}
}
}
The principle of operation is very simple. The left range finder is responsible for the right wheel, and the right for the left
To make it clearer, you can watch a video that shows the process of creating and operating a robot
[media = https: //www.youtube.com/watch? v = VOoBoZF49oI]
This robot is very simple and anyone can do it. It will help you understand the principles of operation of modules such as relays and IR rangefinders and how best to use them.
I hope that you liked this homemade product, remember that homemade products are cool!