Collision Avoider Vehicle With Arduino Nano

Published

Introduction: Collision Avoider Vehicle With Arduino Nano

A collision avoider vehicle could be a very simple robot to start diving into the microelectronics. We will use it to learn the basic elements in microelectronics and improve it to add more sophisticated sensor and actuators.

Basic components

· 1 Mini USB Arduino Nano or clon

· 1 Arduino Nano Shield Extension Board

· 1 Ultrasonic sensor HC-SR04

· 2 Servos 360 degrees continuous rotation (FS90R or similar)

· 1 Battery case for 4xAA

· Breadboard jump wires (F-F, M-F, M-M)

· 2 wheels for servos

· 1 structure for the vehicle (Toy car, milk brick, plywood…)

Additional components

For light indication:

· 1 RGB LED

· 1 mini bread board

· 3 resistances 330W

For remote controlling:

· 1 IR receiver sensor (TSOP4838 or similar)

· 1 IR remote control

For line following/edge detection:

· 2 TCRT5000 barrier line track sensor IR reflective

Alternative elements

You can substitute the servos for:

· 2 DC motor with gear and plastic tire

· 1 L298 Dual H Bridge motor driver controller board module

Step 1: Install the Software and Drivers

We will work with Arduino based micro controllers, you can choose Arduino UNO or any other but because of the requirements and the size I took an Arduino Nano Clone (from China) so with all these options you must use Arduino IDE for coding them.

You can download the software from the official web page of Arduino, and follow the instructions to install it. Once finish, open the Arduino IDE and select the board (in my case I will use the “Arduino Nano” option).

Arduino Nano Clone: A cheap option for an Arduino board is buying a clone board from China. They work with the CH340 chip, and it will require the install of a specific driver. There are many web sites to download the driver for Windows, Mac or Linux and also with the instructions. For Mac, sometimes you can face a problem to recognize the serial port, if it happens to you, try to follow the instructions of this link. If after that you detect the serial port but still have problems, try to select the “ATMega 328P (Old Bootloader)” at Arduino IDE/tools/processor.

Go to coding section to have a look to the code I used for my vehicle. You can surf the web for many other options or coding by yourself if you want.

Step 2: Choose a Nice Structure for Your Vehicle

This time I used a toy car big enough to contains the electronics inside it, but you can use other materials as bricks or plywood to design your own vehicle. Have a look to other option as milk brick.

Is better to spend some minutes planning where to place all the elements before start and confirm that everything will be accommodated. Prepare the structure.

Step 3: Install De Drive

The movement of the vehicle will be through a single axle, in this case the rear axle. You can keep the front just for rolling or, based in your design, use a third wheel or sliding point just for balance your vehicle (as the milk brick, I used the tap as “third wheel”). The turn of your vehicle will be done by changing the speed and/or rotating direction of the servos.

TIP: before customizing your structure, plan the final position of the wheels and check that are not hitting anything. In this example, the center of the servo axle will be located a bit lower than the original toy car axle because the servo wheel is slightly bigger and could hit the mud guards)

Step 4: Install De Ultrasonic Sensor

The ultrasonic sensor will scan the front of the vehicle to identify any obstacle and allow the code reaction. You must place it in the front without any part of the vehicle interrupting the signals.

Step 5: Place the Microcontroller and the Battery Case

You can left now position the remaining elements into the structure, fix them if it is possible or at least be sure the they not damage the connections.

Is very useful to install a switch on/off for the battery if it has not anyone by default. You can also add an IR sensor to start/stop the vehicle.

If you are going to add any additional component, now is the moment.

TIP: to increase the grip of the vehicle, place the battery case or the heavier components over the drive axle or close to it.

Step 6: Coding Section

For this program, you will need also to install some libraries as “Servo.h” (for servo control), “NewPing.h” (to better performance for the ultrasonic sensor) or “IRremote.h” if you are going to use an IR sensor. You can follow the installing instructions in this link.

As an option, you can replace the servos for DC motors, and you will need a dual H bridge motor driver to control them. Probably I will post about it in future updates, but now the code is only working with servos.

Continuous rotation servos are slightly different than the regular servos; sometimes you can modify the regular ones to make them rotate continuously but for this project we will use the FS90R, that are built for our requirement. To operate the regular servos you have to give the degree you want to position it, but for continuous rotation servos you have to consider that:

· 90 will be stop for the servo

· Less than 90 (till 0) will be rotation in one direction where 89 is the slowest speed and 0 the fastest.

· More than 90 (till 180) will be rotation in the opposite direction, where 91 is the slowest and 180 the fastest.

To calibrate your servos, you have to set them to 90 and adjust the small screw opposite the wheel to stop the rotation if it is moving (please, do this before fit them at the structure)

You can use the ultrasonic sensor with many other libraries but be careful while coding it because one problem you can face with these sensors is the idle time you have to wait from the emission of the ultrasonic signal till the reception. Some examples you can find on internet are coding using “delay” but it will affect your robot because it will stop “delaying” any other action for the time you specified. You can know how the ultrasonic sensors works at this link.

Same as the DC motors, I am not going to use the IR sensor in this example, it will be described in future posts.

Microcontroller Contest

This is an entry in the
Microcontroller Contest

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Make it Move Contest

      Make it Move Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    Fun way to give new life to old toys. It would be a lot of fun to do this project with my kids.