0% found this document useful (0 votes)
105 views

Lesson 1 Make The Car Move

This document provides instructions for making an Elegoo Smart Robot Car move using an Arduino IDE. It describes uploading a program to make the car move forward and backward by controlling the left and right wheels independently. It then explains how to write programs for individual motor and wheel movements like turning left. The goal is to break the control programs into smaller functions that can be called to make the car move automatically by a higher level program.

Uploaded by

Adrian Chelen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

Lesson 1 Make The Car Move

This document provides instructions for making an Elegoo Smart Robot Car move using an Arduino IDE. It describes uploading a program to make the car move forward and backward by controlling the left and right wheels independently. It then explains how to write programs for individual motor and wheel movements like turning left. The goal is to break the control programs into smaller functions that can be called to make the car move automatically by a higher level program.

Uploaded by

Adrian Chelen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Http://www.elegoo.

com

Lesson 1 - Make The Car Move

Points of this section


Learning part:
Learn how to use Arduino IDE

Make the car move by uploading program

Preparations:
One car (with a battery)

One USB cable

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

Ⅰ. Introduction of the car

This kit is an extremely flexible vehicular kit particularly designed for education,

competition and entertainment purposes. The upper panel of the kit is directly

compatible with 9-gram steering engine. It also carries supersonic sensor, battery

and other fixed holes to facilitate installation of various sensors. This is a very

funny and versatile robot that meets learning and production purposes. With it,

you can implement diverse interesting ideas, such as Bluetooth and infrared

remote control, automatic avoidance of obstacles, and line inspection.

Let’s describe the small vehicle that will accompany us for a long time in the

future.

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

Each parts of the car is as below:

Function of each part:

1. Battery holder with a switch: provide power supply for the vehicle
2. Electric motor + wheel: drive the vehicle to move
3. acrylic plate: the frame of the car
4. L298N motor driving board: drive the motor to rotate
5. UNO controller board: the brain of the car, controls all the parts
6. V5 sensor expansion board: combined with the UNO, make connection become more easier
7. Servo and cloud platform: enable the GP2Y0A21 distance sensor to rotate 180 degrees
8. Ultrasonic sensor module: distance measurement and obstacle avoidance
9. Line tracking module: black and white sensor for recognition of the white and black lanes
10. Infrared receiver and remote control: provide the infrared remote control function
11. Bluetooth module: provide the Bluetooth control function

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

Ⅱ. Upload program

Because we have uploaded the program to the car in Lesson 0 ,now,you can turn on the power
switch and put the car on the ground. Then you will see the car moving.

Tips: Before turning on the power switch, check whether the battery is fully charged. If the battery
is low, charge it in time. In the charging process, the charger shows a red LED indicates that the
battery is not fully charged, the charger shows a blue LED indicates that it is fully charged.

Ⅲ. Description of Principles

How to use L298N motor driver board


Definition of the connection ports on L298N board have been marked above. The motors should be
connected to the L298N board as the picture above, and if you find the rotational direction of one of
the motors is opposite, please change the connecting position of its black and red wires.
L298N GND is connected to battery box GND;
L298N VCC is connected to battery box VCC;
UNO board is also connected to battery box.
L298N 5V here cannot be connected to UNO 5V;
ENA and ENB control the speed of right motor and speed of left motor separately by PWM.
IN1, IN2, IN3, IN4: IN1 and IN2 are used to control left motor, IN3 and IN4 are used to control right
motor. About the principle, please look at the sheet below: (We take left motor for example)
Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

ENA IN1 IN2 DC MOTOR STATUS

0 X X STOP

1 0 0 BRAKING

1 1 0 FORWARD

1 0 1 BACKWARD

1 1 1 BARKING

Ⅳ. Make the Car Move

TIPS:
When uploading codes, please remove the Bluetooth module from the IO expansion board
(because the serial port for uploading codes and Bluetooth communication is
the same one and there will be conflicts).
You can mount the Bluetooth module after the upload.

before you upload program you should make sure your com is right and click on upload.

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

The first step: Drive the motor

We will try to move the motor without speed controlling. Because it is easy to write program without
speed controlling.

First of all, let's see the connection of the motor the L298N board, we will use Arduino 5, 6, 7, 8, 9, 11
pins to control the car. 9 and 11 pins control the right wheel. 7 and 8 pins control the left wheel. 5 and
6 pins control ENA and ENB.

So the connection is as below:


L298N V5 expansion board
ENA 5
ENB 6
IN1 7
IN2 8
IN3 9
IN4 11

Based on the sheet given above, we first design a simple program to make the right wheel turn 0.5s in
positive direction, stop 0.5s, turn 0.5s in negative direction and stop 0.5s. And the wheel will repeat
the reaction.

Connect the UNO controller board to the computer, open the code file in the path “\Lesson 1 Make
The Car Move\right_wheel_rotation\ right_wheel_rotation.ino”. Upload the program to the UNO
board.

Disconnect it from the computer, and then switch on the car’s power supply. You will see that the right
wheel moves as you expected.
If the car is not moving, press the reset button on the UNO board.
If the moving direction of the motor is different from the direction you set, you can change the
connection of black and red lines from the motor to L298N board.

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

Then, we make the left wheel rotate in the same way.


Connect the UNO controller board to the computer, open the code file in the path “Lesson 1 Make
The Car Move\Left_wheel_rotation\ Left_wheel_rotation.ino”. Upload the program to the UNO
board.

Disconnect it from the computer, and then switch on the car’s power supply. You will see that the right
wheel moves as you expected.

The second step: Move forward and backward

After finishing debugging the car, you can write programs to make the car move.
Below is the way how car moves:
CAR forward back stop
Left wheel Forward back stop
Right wheel Forward back stop

CAR Turn left Turn right stop


Left wheel back Forward Stop
Right wheel forward back stop
Next, we will write a simple program to make the car go forward 0.5s , then stop 0.5s, then back up
0.5s and then stop 0.5s.

Connect the UNO controller board to the computer, open the code file in the path “Lesson 1 Make
The Car Move\forward_back\forward_back.ino”. Upload the program to the UNO board.

Upload the program to the UNO board, disconnect it from the computer, and then switch on the car’s
power supply. You will see that the right wheel moves as you expected.

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

The third step: Write the program

It may be a difficult for you to write the whole program to make the car move automatically. So we
separate the movements into different function, for example moving forward and turning left. And
when we write the program in the final step, we can call the function.
Next, we begin to write programs for each movement:

The fourth step: Move automatically

We start to write program to make the car move automatically: go forward 0.4s - back up 0.4s - turn
left 0.4s - turn right 0.4s.

Connect the UNO controller board to the computer, open the code file in the directory “Lesson 1
Make The Car Move\AUTO_GO_\ AUTO_GO_.ino”. Upload the program to the UNO board.

Disconnect it from the computer, and then switch on the car’s power supply. You will see that the
wheel moves as you expected.

The fifth step: speed_control

The code to achieve the function is to control the speed of the car: go forward and reduce the speed
 stop 1s  running back and accelerate  stop 2s.

Connect the UNO controller board to the computer, open the code file in the directory “Lesson 1
Make The Car Move\speed_control\ speed_control.ino”. Upload the program to the UNO board.

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).
Http://www.elegoo.com

The sixth step: car_control

The code to achieve the function is to control the speed of the car and you can set the speed you like
to change the value of CAR_SPEED

Connect the UNO controller board to the computer, open the code file in the directory “Lesson 1
Make The Car Move\speed_control\ car_control.ino”. Upload the program to the UNO board.

http://www.elegoo.com
2019.7.15

Tips: If you have any questions or run into any problems during assembling and testing Smart Robot Car please feel free to contact us at
[email protected] or [email protected] (Europe customers).

You might also like