Imagine you’ve just moved into a new place. You need furniture ASAP but you don’t have measure tape with you. Well, this Parallax laser Arduino robot would come in very handy!
In the previous posts, How To Make Your Own Robotand How To Make Your Own Robot (Part 2), we showed a simple way to build your own robot from scratch using Arduino UNO R3. In this article, we will further improve the functionality of the robot by making it mobile and adding laser range finder (LRF) to allow the robot to detect objects and measure distances.
The laser sensor will allow us to obtain more accurate and reliable data. This Arduino robot is designed to be autonomous. It’ll be able to detect and avoid obstacles as they roam around.
The robot is designed to:
Move forward, backward, turn 90 degree left & right and turn 45 degree left & right.
Avoid obstacles by moving in different directions based on best available paths.
Measure distance from various directions (forward, 90 degree left & right, 45 degree left & right.
Make decision on which direction it will take (forward, backward, left or right) based on the longest distance available.
The sensor is attached to a servo so the robot can pan left and right to take several measurements. The distance measured is then displayed on a small OLED. We’ll use stepper motor for smooth, quiet operation.
We will discuss the building of this Arduino robot step by step, first step is the basic installation of the chassis, motors and Arduino/motor shield. Then a small program was shown to test the motors to ensure proper connections and software installation. Then, in the next article we will add on the rest of the devices one by one, followed by programs to test correct installation and connection. By doing this approach, if any problem occurs, it will be easier to fix.
The hardware required for this robot are available in many electronics shops, we provide examples of shops in the Hardware list.
The chassis from Parallax is made from strong aluminium. It is specifically designed for servo instead of stepper motor, so we need to make a little modification to the design.
First, we will cut the lower part of both sides of the chassis to save space for motor attachment. Use Dremel to get a clean cut.
We’re using NEMA 17 stepper motor, which has a resolution of 200 steps/revolution. It can be powered at 12V 350mA.
To install motors we need 6.5 cm x 4.5 cm acrylics for mounting motor into the chassis as shown in Figure 1. Cut the acrylics using hacksaw and drill the holes by using Dremel. Use M2 x 10mm screws to attach motors into the acrylics mounting; it requires 8 screws for both motors. Then, attach the acrylics into the chassis.
Figure 1. Mounting stepper motor to 6.5 x 4.5 cm acrylic board
Cut 15 cm x 8 cm acrylics for the base to attach Arduino and OLED display (Figure 2). Install the acrylics base using 4 spacers and screws, then install tail wheel using the pin provided.
Figure 2 Chassis, tail wheel and 15 x 8 acrylic board for the base
Figure 3. Wheels and shaft connectors
Figure 4. Stepper motors and tail wheel attached to the chassis
To install the wheels, we use shaft connectors as shown in Figure 3. There is one small modification required. The diameter of the hole of the shaft is 4mm, whereas the stepper motor’s shaft has diameter of 5mm. So we need to make the connector’s hole bigger to 5 mm. Use round file or Dremel to make the hole bigger. Do it carefully.
Figure 5. Acrylic base installed to chassis
Pull the cables from motors through the holes provided to the top, and put the battery under the chassis using double tapes. Lipo (Lithium Polymer) battery is the perfect solution for this project as it gives 11.1V 800mAh~1000mAh, which allowswill runtime for more than 1 hour. It’s also rechargeable. But we need a special charger for this battery. If you are an aeromodeller or RC car driver then you must be familiar with this type of battery. It can be replaced with 6 or 8 x AA batteries that provide 9-12 V.
Figure 6. Attach battery to chassis using double tape
Connect cable from motors to motor shield
Adafruit motor shield specs – Adafruit
2 connections for 5V ‘hobby’ servos connected to the Arduino’s high-resolution dedicated timer
4 H-Bridges: TB6612 chipset provides 1.2A per bridge (3A for brief 20ms peaks) with thermal shutdown protection, internal kickback protection diodes. Can run motors on 4.5VDC to 13.5VDC.
Up to 4 bi-directional DC motors with individual 8-bit speed selection.
Up to 2 stepper motors (unipolar or bipolar) with single coil, double coil, interleaved or micro-stepping.
Tested compatible with Arduino UNO, Leonardo, ADK/Mega R3, Diecimila & Duemilanove. Works with Due with 3.3v logic jumper. Works with Mega/ADK R2 and earlier with 2 wire jumpers.
5v or 3.3v compatible logic levels – jumper configurable.
This motor shield is capable of running 2 stepper motors and 2 servos. The beauty of this stepper motor shield is that it does not use any pin in Arduino because it is connected through I2C. The only pin needed is for servo. Just follow the instruction to connect the wires from motors.
Figure 7. Connecting stepper motors to motor shield
Figure 8. Arduino and motor shield attached to acrylic base
Now simply install the wheels and battery connector as shown below.
Figure 9. Stepper motor’s cable connected to motor shield
Install Software and upload the code
We are now ready to run our first code. First, we need to install Arduino IDE from Arduino website and motor shield library from Adafruit. After successful installation, copy the following source code to the Arduino.
This code is very simple. It allows the robot to make 90 degree turns to the left and 90 degree turns to the right. It also allows turning back to original position, moving forward for 400 steps and moving backward to the original position. Within the loop we run Motor function, which has 2 parameters. The first parameter tells how many steps the motor must turn and the second parameter tells about the direction (e.g. forward, backward, left and right).
When the program is running, the Arduino robot will move like in the above video.
In the next article, we will continue adding the rest of the parts such as the servo and Laser Range Finder (LRF) and writing a program that allows the robot to move around autonomously. So stay tuned for my next article!
Hailing from Melbourne, Purnomo is a retiree and electronics enthusiast. Currently he is keeping himself busy with various open hardware projects using Arduino and Raspberry Pi. Besides electronics, he is also passionate about aero modelling and astronomy.