How To Make A Self-propelled All-terrain Vehicle With Sonar

Table of contents:

How To Make A Self-propelled All-terrain Vehicle With Sonar
How To Make A Self-propelled All-terrain Vehicle With Sonar

Video: How To Make A Self-propelled All-terrain Vehicle With Sonar

Video: How To Make A Self-propelled All-terrain Vehicle With Sonar
Video: How I Built My All-Terrain Tracked Vehicle out of Scrap Metal for Under $400 (Bug-Out Vehicle) 2024, November
Anonim

Continuing the theme of toy all-terrain vehicles with Arduino. We have already made a radio-controlled all-terrain vehicle with you from a smartphone via Bluetooth. Now we will make an all-terrain vehicle that drives itself, avoids obstacles, and also signals with "headlights" about turning or stopping.

Toy all-terrain vehicle with sonar
Toy all-terrain vehicle with sonar

It is necessary

  • - Arduino UNO or equivalent;
  • - ultrasonic range finder (ultrasonic module) HC-SR04 or similar;
  • - L9110S motor driver or analog;
  • - tracked platform for the Pololu Zumo tank or similar;
  • - a piece of fiberglass according to the size of an Arduino board or a shield for prototyping;
  • - 2 electric motors suitable for the selected chassis;
  • - 2 white LEDs (headlights), 2 red LEDs (rear lights) and 4 180-220 Ohm resistors;
  • - batteries (1 "Krona" or 4-6 finger batteries);
  • - connecting wires;
  • - soldering iron;
  • - a computer;
  • - fasteners - 6-10 bolts M2, 5, washers, nuts to them.

Instructions

Step 1

The first step is to assemble the platform. In one of the previous articles, we looked in detail at how to make the chassis of a toy ATV. Here, the steps will be exactly the same. Therefore, we will not dwell on this in detail. The assembled chassis for the all-terrain vehicle with the Arduino board installed on them is shown in the photo.

Self-propelled toy all-terrain vehicle chassis
Self-propelled toy all-terrain vehicle chassis

Step 2

Now it's the turn of the electronics. Let's look at the connection diagram first. Please note that all LEDs are connected via resistors of about 200 ohms. The sonar is connected to two arbitrary digital pins of the Arduino and a + 5V power supply. The connection of the motor driver to the Arduino and to the motors can be seen in the diagram. If there are any ambiguities - read the previous article, where we considered this in more detail, or ask questions in the comments.

Toy ATV connection diagram
Toy ATV connection diagram

Step 3

Let's assemble the heart and brain of our toy all-terrain vehicle according to the above diagram. You can mount everything on a circuit board - this is much more convenient for mounting and possible future modifications. In the photo, the electronic components are placed on a special shield for prototyping for Arduino Uno. The sonar looks straight ahead of the vehicle. The rear LEDs will mimic the brake lights, the front LEDs, respectively - the headlights.

Assembling the electronics of the toy ATV
Assembling the electronics of the toy ATV

Step 4

Time to write a control program for our all-terrain vehicle. The sketch code (program for Arduino) is shown in the illustration.

The main nuance in this sketch is working with the sonar. The bottom line is that we send a short pulse - a trigger, measure the delay time of the echo - reflection, and determine the distance to the target by the delay time. If the distance is less than the specified one (in the sketch - 20 cm), then the all-terrain vehicle will go around it.

We considered the motor control algorithm in the previous article. When turning, the all-terrain vehicle will turn on "turn signals", when stopped - a brake light. When an obstacle is detected, the headlights will turn on and the ATV will go around it. To make the all-terrain vehicle more "intelligent", let us set an arbitrary direction for avoiding obstacles.

Comments in the code explain the entire program in more detail.

Sketch for a toy all-terrain vehicle
Sketch for a toy all-terrain vehicle

Step 5

"Fill" the sketch into Arduino (we have already considered several options in the previous articles on how to load the program into the Arduino). We connect the shield with the electronic components of the all-terrain vehicle to the Arduino board. We serve food. And we watch how our all-terrain vehicle "comes to life".

Recommended: