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

Tutorial Documentation

Uploaded by

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

Tutorial Documentation

Uploaded by

Nailson costa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

1 / 75

Multifunctional remote control car -V2.0


ZYC0098
V2.02.304.07
1 / 75

Three Steps To Move


This product has uploaded the "infrared remote control" program to the main control board before leaving the factory. After

the assembly is completed and the battery is installed, the infrared remote control can be realized. Then follow the guide to

operate!

Step 1: You need to complete the assembly of the car according to the assembly manual or video guidance;

Step 2: Install the battery (make sure the power is sufficient), turn on the switch of the battery box, and the status light of the

motherboard is normally on;

Step 3: Align the infrared remote control with the "infrared receiver" on the main board of the car to control the movement

of the car.
2 / 75
3 / 75

Introduction to the tutorial


This tutorial includes 5 files as shown in the figure below to help you learn more about electronics and programming:

"0_Assembly_guide": This folder stores the robot assembly guide. In order to complete the assembly accurately and quickly,

please be sure to review it in detail and assemble it according to this manual;

"1_Arduino software": This folder stores the software download link guide and software installation steps;
4 / 75

"2_Libraries": Change the folder to contain the required library file compression package, select this path to add the

compression package when adding the library file in the IDE;

"2_Arduino_Code": This folder is used to store code files, and each code file is uploaded and used independently;

"4_Bluetooth_APP": This folder stores the Bluetooth APP installation package and APP setting guidance tutorial. This

Bluetooth APP is only used in products with a Bluetooth module. If there is no Bluetooth module, please ignore it.
5 / 75

Table of contents
Three Steps To Move ............................................................................................................................................................. 1

Introduction to the tutorial ......................................................................................................................................................3

1. Bluetooth remote control code burning .............................................................................................................................10

Connect the motherboard to the computer with a USB cable ........................................................................................ 11

Unplug the Bluetooth module from the main control board .......................................................................................... 11

Click the "upload" button to compile and upload the code. ...........................................................................................13

2. Bluetooth remote control APP .......................................................................................................................................... 14

2.1 Install and set up APP ............................................................................................................................................... 14

The three control mode buttons are set to send data as follows ..................................................................................... 19

3.The first program code - Blink .......................................................................................................................................... 21

3.1 About this lesson: ..................................................................................................................................................... 21

3.2 Main control board : ...............................................................................................................................................21


6 / 75

3.3 Make your own "Blink" sketch .............................................................................................................................. 22

4. Motor Testing ................................................................................................................................................................ 30

4.1 Course Introduction .................................................................................................................................................. 30

4.2 How the TMI8549 motor driver chip works ..............................................................................................................30

4.3 wiring diagram ......................................................................................................................................................... 31

4.4 code analysis ............................................................................................................................................................ 32

5. Follow the car ...................................................................................................................................................................34

5.1 Course Introduction .................................................................................................................................................. 34

5.2 Component introduction ........................................................................................................................................... 34

5.3 How does ultrasound work? ......................................................................................................................................36

1. Transmitter ( trig pin) sends signal: high frequency sound; .........................................................................................36

2. When the signal hits an object, it is reflected; ............................................................................................................. 36

3. Receiver (echo pin): Receives the signal reflected from it. ......................................................................................... 36
7 / 75

5.4 servo motor .............................................................................................................................................................. 37

Ultrasonic and servo wiring diagram .............................................................................................................................. 40

5.6 LM393 module: ........................................................................................................................................................ 41

5.7 be adjusted by the potentiometer knob : ................................................................................................................. 42

How does the infrared detection module work? ..............................................................................................................42

5.8 wiring diagram ......................................................................................................................................................... 44

5.9 Follow the trolley principle .......................................................................................................................................45

5.10 code analysis .......................................................................................................................................................... 45

6. Obstacle Avoidance Car ....................................................................................................................................................49

6.1 Course Introduction .................................................................................................................................................. 49

6.2 Principle of obstacle avoidance .................................................................................................................................49

6.3 Code upload: ............................................................................................................................................................ 49

7. Tracking Car .....................................................................................................................................................................53


8 / 75

7.1 Four-way tracking module: .......................................................................................................................................53

How does the four-channel tracking module work? ........................................................................................................ 53

7.2 Tracking module wiring diagram ............................................................................................................................... 54

7.3 code analysis ............................................................................................................................................................ 55

8 Infrared Control .................................................................................................................................................................61

8.1 Course Introduction .................................................................................................................................................. 61

8.2 Device introduction .................................................................................................................................................. 61

8.3 Infrared remote control principle .............................................................................................................................. 62

8.4 Infrared remote control settings ................................................................................................................................ 63

8.5 code analysis ............................................................................................................................................................ 64

9 Bluetooth Remote Control .................................................................................................................................................67

9.1 Course Introduction .................................................................................................................................................. 67

9.2 BT05 Bluetooth ........................................................................................................................................................ 67


9 / 75

9.3 code analysis ............................................................................................................................................................ 68

10 Integrated Intelligent Control .......................................................................................................................................... 70

10.1 Course Introduction ................................................................................................................................................ 70

10.2 Bluetooth integrated control code analysis ..............................................................................................................70


10 / 75

1. Bluetooth remote control code burning


Make sure you have followed the instructions in the 1_Get_start folder to create the programming environment.

Open the code file (path: 2_Arduino_Code\7_Bluetooth_smart_car\7_Bluetooth_smart_car.ino)


11 / 75

Connect the motherboard to the computer with a USB cable

Unplug the Bluetooth module from the main control board

Open the "Tools" menu option, click "Development Board", select the board type Arduino Uno.
12 / 75

Then select the COM number of the serial port, here it is COM8, but actually everyone’s COM number will be different.
13 / 75

Click the "upload" button to compile and upload the code.

At the bottom of the editor, you can see that the upload and writing are 100% complete. If there is an error or failure, please

check whether the board type and serial number are displayed normally.

Plug in the Bluetooth module again , and then start the installation and setting of the Bluetooth APP, please see the next

section.
14 / 75

2. Bluetooth remote control APP


2.1 Install and set up APP
Open the directory 3_Bluetooth_APP, install "bluetooth-V1.95.apk" to the Android phone and open it

Next, we use an Android mobile phone to demonstrate how to control the car through this application: First, turn on the

Bluetooth function switch of the mobile phone

Open the APP just installed and make sure that the robot car is powered on, and the Bluetooth is in the state of slow flashing
15 / 75

and waiting for connection.

As shown in the figure, under the "Device Connection" menu, click the middle icon to search for Bluetooth

Find BT05 in the bluetooth device that appears, and then click the "+" on the right to connect. When the icon turns into an

"X", it means the connection is successful.


16 / 75

After the connection is successful, click the fourth "button control" option in the bottom menu bar to enter the "button

control" interface

Then click the "Edit Mode" switch to enter the edit mode.

First add direction and stop buttons FORWARD, LEFT, RIGHT, BACK, STOP
17 / 75

Click the button to edit, first add a name: forward (default will be converted to capital letters) , F is the Bluetooth

information to be sent when the button is pressed, and S is the information when it is released. That is, F is sent when

pressed, S is sent when released, and then click OK to exit.


18 / 75

In the same way, modify LEFT, RIGHT, DOWN, STOP. The corresponding information sent is:

Button press loosen


FORWARD F S

BACK B S

LEFT L S

RIGHT R S

STOP S

Add three more buttons for the control mode: OA/FOLLOW/TRACKING


19 / 75

Taking the setting of the obstacle avoidance mode button as The three control mode buttons are set to send data as

an example, 1 is sent when the switch is pressed, but no follows

need to be sent when the switch is released.

Button Press loosen


FREE 0

OA 1

FOLLOW 2

TRACKING 3
20 / 75

All settings are completed, turn off the editing mode, and now you can try to remotely control your car

So far, you have learned how to realize the complete process of Bluetooth remote control from scratch. The following

courses will introduce and guide you to learn this kit in detail!
21 / 75

3.The first program code - Blink


3.1 About this lesson:
In this lesson, you will learn how to program your control board to blink the built-in LED, as well as learn the basic steps

to download the program.

3.2 Main control board :


This kit provides a motherboard compatible with UNO. The motherboard integrates the motor driver module, infrared

module, and pins are well packaged and drawn out, such as the pins of the Bluetooth module. It also has an LED, which

you can see from the program sketch control it .


22 / 75

When you connect the board to the computer with the USB cable , you may find that its LED is already blinking, this is

because the board is pre-installed with the "Blink" sketch.

3.3 Make your own "Blink" sketch

board using our own Blink sketch , and then change its blink rate. Now keep the board connected to the computer, set up

the Arduino IDE and make sure you can find the correct serial port , and upload the program to test.

The Arduino IDE includes a number of example sketches that you can load and use , including a "blink" example sketch
23 / 75

for making an "L" LED . In the IDE menu system File > Examples > 01. The " Blink " sketch you will find in Basics .

The example sketches included with the Arduino IDE are "read only". That is, you can upload them to the dashboard , but

if you change them, you can't save them as the same file. So the first thing you need to do is save your own copy.

From the Arduino IDE's File menu, select "Save As.." and save the sketch as "MyBlink".

You've saved a copy of the "flicker" in your sketchbook, if you ever want to find it again, just open it using the " File >

Open Recent " menu option.


24 / 75

Connect the Arduino board to the computer using a USB cable and check that the Board Type and Serial Port are set

correctly.
25 / 75

Note: The board type here is Uno and the serial port is COM5 .

Actually the serial port appears to be different for everyone, even though COM 5 is selected here , it could be COM3 or

COM4 on your computer. A correct COM port should be COM X (arduino X XX) standard.

After clicking the "Upload" button, the program starts to upload. At this time, the LED on the Arduino will start to blink

as the sketch is transferred.


26 / 75

The transfer is complete and "Upload complete" appears

"Compile Sketch.." process , you might get an error message:

This could mean that your board is not connected at all, or that the CH340 driver is not installed (if required) or that the

serial port is selected incorrectly . If you encounter this situation, please check your IDE settings and motherboard
27 / 75

connection, and ask business personnel for help after taking a screenshot .

When the upload is complete , the board LED should reboot and start blinking. Note that a large part of this sketch

consists of annotations. These are not actual program instructions; rather, they explain how to make the program work.

They are there for your easy readability . Everything between " /* " and " */ " at the top of the sketch is a block comment ,

which explains the purpose of the sketch.

A single-line comment starts with "//" and everything up to the end of the line is considered a comment.

The first part of code is:


// the setup function runs once when you press reset or power the board
void setup () {
// initialize digital pin LED_BUILTIN as an output.
pinMode (LED_BUILTIN, OUTPUT);
}

Every sketch needs a "setup" function , aka "Void setup()" function, which is executed when the reset button is pressed. It

is executed whenever the board is reset for any reason, such as powering on for the first time or after uploading a sketch .
28 / 75

The next step is to name the pin and set the output, here set " LED_BUILTIN " as the output port. On most Arduinos,

including UNO , pin 13 is the pin corresponding to the LED, and for the convenience of programming, the program has

set the LED_BUILTIN variable to this pin, so it is not necessary to rename it to pin 13 for direct use.

The sketch must also have a " loop " function. Unlike the "Set" function, which only runs once, after a reset, the "Loop"

function will restart immediately after finishing running the command.

// the loop function runs over and over again forever


void loop () {
digitalWrite (LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay ( 1000 ); // wait for a second
digitalWrite (LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay ( 1000 ); // wait for a second
}

Inside the loop function, the command first turns on the LED pin (high level), then "delays for 1000 milliseconds (1

second), then turns off the LED pin and pauses for one second.

You are now going to make your LED blink faster. The key, as you might have guessed, is changing the parameters in "
29 / 75

delay ()".

This delay time is in milliseconds, so if you want the "LED" to blink twice as fast, change the value from "1000" to

"500" . This will pause for half a second on each delay, instead of a second. Upload the sketch again and you should see

the "LED" start blinking faster .

So far, you have understood and mastered the basic Arduino programming knowledge and the basic steps of downloading

the program, which will lay a good foundation for learning complex projects later.
30 / 75

4. Motor Testing
4.1 Course Introduction
In the previous class, we learned the basic method of uploading programs. In this class, we will learn and master the control

principle of car movement.

4.2 How the TMI8549 motor driver chip works

1、ENA controls enable , PWM output, and different combinations of IN1 and IN2 control different outputs

2、out1 , out2 , out3 , out 4 high and low level control motor rotation;
31 / 75

4.3 wiring diagram


32 / 75

4.4 code analysis


Open the code file (path: 2_Arduino_Code\1_Motor_test\1_Motor_test.ino)

Define the enable terminal pwm pin and IN1/IN2 input terminal

Define the motor speed variable, you can modify the value by yourself (100~220 is more suitable) to get different

movement speeds

The setup function defines the baud rate as 9600 and the pin as output
33 / 75

The loop function loop( ) repeatedly executes forward, backward, left turn and right turn for 3 seconds each. Of course, you

can also change 3000 to 1000 to see how it works.


34 / 75

5. Follow the car


5.1 Course Introduction
Ultrasonic distance measurement is a very useful and widely used measurement method. This lesson mainly understands the

working principle of the ultrasonic module, masters the connection of the ultrasonic circuit diagram, and learns the method

of ultrasonic module distance measurement through programming.

5.2 Component introduction


HC-SR04 ultrasonic module:
35 / 75

working voltage DC-5V

Working current 15mA

Working frequency 40KHz

Distance range 2cm ~ 400cm _

Measuring angle 15 °

Input trigger signal 10 US TTL pulses

Output echo signal Output TTL level signal, proportional to the range
36 / 75

5.3 How does ultrasound work?

1. Transmitter ( trig pin) sends signal: high frequency sound;

2. When the signal hits an object, it is reflected;

3. Receiver (echo pin): Receives the signal reflected from it.


There are many methods of ultrasonic distance measurement. The principle of this system in ultrasonic measurement is:

detect the transmission time of the ultrasonic wave from the ultrasonic transmitter through the gas medium to the receiver,

multiply this time by the speed of sound in the air, and obtain the sound propagation time distance.

The ultrasonic transmitter emits ultrasonic waves in a certain direction, and the MCU starts timing at the same time. The

ultrasonic waves are emitted in the air, and return immediately when encountering obstacles on the way, and the

ultrasonic receiver stops timing immediately after receiving the reflected waves.

T recorded by the timer , the distance ( s ) from the launch point to the obstacle can be calculated .

Formula: S = VT/2
37 / 75

Four factors limit the maximum measurable distance of an ultrasound system: the amplitude of the ultrasound waves, the

texture of the reflector, the angle between the reflected and incident sound waves, and the sensitivity of the receiving

transducer. The ability of the receiving transducer to receive the sound pulse directly will determine the minimum

measurable distance.

5.4 servo motor


SG90 module:

The control signal enters the signal modulation chip receiver from the channel to obtain a DC bias voltage. It has an internal

reference circuit which generates a period of 20ms and a width of a reference signal of 1.5ms. The obtained DC bias voltage
38 / 75

is compared with the voltage of the potentiometer to obtain a voltage difference output. Finally, the positive and negative

output of the voltage difference is sent to the motor driver chip to determine the forward and reverse rotation of the motor.

When the motor speed is fixed, the driving potentiometer rotates through the cascade reduction gear, so that the voltage

difference is 0, and the motor stops rotating.

How does the SG90 module work?


Servo control: The control of the servo generally requires a time base pulse of about 20ms. The high-level part of this pulse

controls the angle. The pulse range is generally 0.5ms~2.5ms. Take the servo motor with a servo of 180 degrees as an

example.

0.5ms 0°
1.0ms 45°
1.5ms 90°
2.0ms 135°
39 / 75

SG90 module installation method: top view

As shown in the picture above (left), the front of the car is facing upwards. When installing the ultrasonic wave, make

sure that the initial position is on the right. The operation method is to use the white mechanical handle (as shown in the

right picture above) to try to twist the central axis of the servo motor, and measure the limit position 0° and 180°. To

ensure that the ultrasonic rotation range (0~180°) is left, front, and right, it is necessary to install the ultrasonic wave at

90°, which is the front.


40 / 75

Ultrasonic and servo wiring diagram


41 / 75

5.6 LM393 module:

The induction module light can sense the environment. It has a pair of infrared emitting and receiving tubes. When the

detection direction encounters an obstacle, the infrared receiving tube receives the reflected infrared frequency signal . After

processing by the comparison circuit, the indicator light is on, and the signal output interface Output digital signal (low level

signal) . The effective sensing distance range is 2~30cm, the working voltage is 3.3V~5V , and it has the characteristics of

small interference, easy assembly, and convenient use .


42 / 75

5.7 be adjusted by the potentiometer knob :


We hope that only the power light is on when no object is detected, and the signal light is off (as shown in the left picture

below), and the signal light is on when an object is detected (as shown in the right picture below). If no object is detected,

both lights are on. This is because the detection distance is too far, and it needs to be adjusted counterclockwise to reduce

the sensitivity, but it cannot be adjusted too small.

How does the infrared detection module work?


1. When the module detects the signal of the obstacle ahead, the indicator light on the green circuit board lights up, and the

OUT port continuously outputs a low-level signal. The detection distance is 2~30cm from the module, and the detection

angle is 35°.
43 / 75

2. The sensor actively detects infrared reflections, so the shape and shape of the reflectivity target is the key to the detection

range. Among them, the black detection distance is small, and the white detection distance is large.

3. The output port OUT of the sensor module can be directly connected to the IO port of the microcontroller ;

4. A 3-5V DC power supply can be used to power the module . When the power is turned on, the red power indicator light is

on.
44 / 75

5.8 wiring diagram


45 / 75

5.9 Follow the trolley principle


If the signal is detected by the right sensor and not by the left sensor, the car turns to the right. Similarly, the left sensor

detects a signal and turns to the left, and the sensors on both sides detect a signal and back off. Otherwise, it is judged that

the ultrasonic detection distance in the front is between 10 and 30cm, and then follow forward, and stop when it is greater

than 30cm or between 5 and 10cm. Finally, when the ultrasonic distance is too close to less than 5cm, the car will retreat.

5.10 code analysis


Open the code file (path: 2_Arduino_Code\2_follow_test\2_follow_test.ino)

Define servo, left and right infrared sensors and ultrasonic pins
46 / 75

Define ultrasonic detection distance, left and right sensor variables

Initialize the setup, set the servo pin and sensor input and output

Follow function follow( )


Judging whether the left and right sensors detect objects, combined with the obtained front distance, to realize the following

task
47 / 75

Ultrasonic detection distance function


float GetDistance ()
{
float distance;
// Send a low short pulse to Trig to trigger the ranging
digitalWrite (Trig, LOW); //Send a low level to Trig
delayMicroseconds(2);
digitalWrite(Trig, HIGH);
delayMicroseconds(10);
digitalWrite(Trig, LOW);
48 / 75

distance = pulseIn(Echo, HIGH) / 58.00;


Serial.print("Distance = ");
Serial.println(distance);//The serial output distance is converted into cm
return distance;
}

Cart move and stop functions (code collapsed)


49 / 75

6. Obstacle Avoidance Car


6.1 Course Introduction
In the previous course, we have understood and learned the relevant knowledge of ultrasonic, servo motor and LM393

module. In this course, we will complete a car with automatic obstacle avoidance.

6.2 Principle of obstacle avoidance


The ultrasonic detection distance of the trolley is less than or equal to 20cm in front (that is, when encountering an obstacle),

the trolley stops the servo motor and drives the ultrasonic wave to turn left to obtain the distance of the obstacle on the left,

then turn right and obtain the distance of the obstacle on the right and save it to the variables "leftDistance" and

"rightDistance" respectively middle. Then compare the distance, which side has the greater distance, that is, turn to which

side without being hindered, so as to avoid obstacles.

6.3 Code upload:


Open the code file (path: 2_Arduino_Code\3_Ultrasonic_obstacle_avoidance\3_Ultrasonic_obstacle_avoidance.ino)

The function of defining servo, sensor pin and obtaining ultrasonic distance in the code is consistent with the last lesson.
50 / 75

The moving function adds a slow function forward_U(), and switches to slow forward when the distance to the obstacle is

less than 50cm.

The obstacle avoidance function Ultrasonic() saves the detected values of the left and right infrared sensors and the distance

values measured by ultrasonic waves.

When the distance is less than 25cm, the car brakes and stops, and the left and right distances are detected by ultrasonic
51 / 75

Comparing the distance between the left and right sides, the car turns to the side with the larger distance, and the delay(380)

function represents the turn execution time, the larger the value, the larger the turn.

When the ultrasonic detection distance is greater than 25, it is determined whether the obstacles are detected on both sides
52 / 75

of the car and the corresponding avoidance is carried out. Otherwise, the default is to move forward. While moving forward,

the ultrasonic wave continuously feedbacks the distance ahead.


53 / 75

7. Tracking Car
7.1 Four-way tracking module:

How does the four-channel tracking module work?


The sensor belongs to infrared reflection detection, that is, the color of the surface of different infrared light objects has

different reflection intensity characteristics, and the infrared light is continuously emitted to the ground during the driving

process of the car . When the infrared light meets the white floor, it is diffusely reflected and the reflected light It is received

by the receiving tube installed in the car ; if it encounters a black line, the infrared light is absorbed, and the receiving tube

on the car does not receive the infrared light . Therefore, the position of the black line and the driving route of the car can be
54 / 75

determined based on whether the reflected infrared light is received or not.

7.2 Tracking module wiring diagram


55 / 75

7.3 code analysis


Open the code file (path: 2_Arduino_Code\4_tracking_test\4_tracking_test.ino)

Define four tracking sensor variables and set pins as inputs

The detection information of the 4-way tracking module is obtained in the loop function body, and the car motion control is

carried out according to the detection results (high level means the black line is detected).

On the basis of the original move function, the functions of turning left big turn and right big turn are added, left_M() and

right_M(). The difference between turning big turn and small turn is mainly adjusted in the input pwm of ENA.
56 / 75

In the loop() function, the values of the four sensors are stored in variables.

After the code is uploaded, we open the serial port monitor to view the values read by the four infrared sensors, and see that

the four values are separated by "--" for easy viewing. Under normal conditions, the reading value of the sensor that detects

the black line is 1, and other values are 0. When we see the following numerical situation, the IN1(T_Sensor1) sensor

detects the black line, and the other sensors do not detect the black line.
57 / 75

In the following figure, after the power is energized, the power lamp D5 turns on, and the four infrared sensors connected

from the top to the bottom correspond to four lamps respectively D1/D2/D3/D4.

When the IN1 (T_Sensor1) sensor detects the black line, the corresponding lamp (D1 lamp) turns off and the rest lights on.
58 / 75

When the black line is detected but the corresponding lamp is not off, it is necessary to turn the potentiometer with a

screwdriver (circled position) and slowly adjust to the critical value of the lamp just off.
59 / 75

In the same way, four infrared sensors are used to detect the black line in turn to adjust the potentiometer to ensure that the

light can be correctly turned off each time the black line is detected.

After all the sensors are tested, the car can be put on the black route to walk. The code to control the car to realize the

tracking function is as follows:


60 / 75
61 / 75

8 Infrared Control
8.1 Course Introduction
Infrared remote control is a widely used remote control method. The car is already equipped with an IR receiver, thus

allowing it to be controlled using an IR remote. This lesson mainly understands the infrared remote control and receiver ,

the principle of infrared remote control and the idea of learning infrared remote control programming.

8.2 Device introduction


infrared receiver Infrared remote control
62 / 75

8.3 Infrared remote control principle


The general infrared remote control system consists of two parts: sending and receiving. The sending part is composed of an

infrared remote control, and the receiving part is composed of an infrared receiving tube. The signal sent by the infrared

remote control is a series of binary pulse codes. In order not to be interfered by other infrared signals during wireless

transmission, it generally needs to be modulated at a given carrier frequency, and then transmitted through an infrared

emitting phototransistor. The infrared receiving tube filters out other noise waves, only receives the signal of a given

frequency, and restores it to the demodulated binary pulse code. The built-in receiving tube sent by the infrared

light-emitting diode transforms the optical signal, amplifies the signal through the amplifier in the IC, restores the original

code sent by the remote control through automatic gain control, band-pass filtering, demodulation, and wave formation, and

outputs the signal through the infrared receiving module The pin identifies the circuit that enters the appliance.

The coding scheme that matches the infrared remote control protocol is: NEC protocol. Next, let us understand what is NEC

protocol.

(1) 8 address bits, 8 sequence bits Address bits and sequence bits are transmitted twice to ensure reliability
63 / 75

(3) Pulse position modulation

(4) The carrier frequency is 38 kHz

(5) The time of each bit is 1.125 ms or 2.25 ms

8.4 Infrared remote control settings


Moving direction and address code

forward //16712445--"+";

backward //16750695--"-";

Turn left //16769055--<<;

Turn right //16748655-->>;

Stop //16754775--">";
64 / 75

8.5 code analysis


Before uploading the code, make sure that the library corresponding to the infrared module has been installed correctly,

otherwise an error will be reported


65 / 75

Open the code file with Arduino IDE (path: " 3_ Arduino _Code

\5_Infrared_remote_control_mode\5_Infrared_remote_control_mode .ino " )

Unplug the bluetooth before uploading the code!

Import the infrared module library and define the encoding variables sent by the infrared remote control

Define the pins for the IR receiver

Enable the infrared module, define the variable val and time preMillis used to receive the code

Analyze the received infrared code in the loop function, and then control it through "switch...case" combined with the
66 / 75

movement function

When the time is greater than 500 and the signal is still not received, stop the car.
67 / 75

9 Bluetooth Remote Control


9.1 Course Introduction
Bluetooth remote control is a very convenient and efficient control method. The car is already equipped with a Bluetooth

module , so it can be controlled through a Bluetooth APP . This lesson mainly understands the principle of Bluetooth remote

control, can wirelessly control your car in a specific space and learn the programming ideas of Bluetooth remote control.

9.2 BT05 Bluetooth

Bluetooth is a wireless technology standard for exchanging data between different devices at close range using short-wave

UHF radio waves in various fields including industry, science and medicine. The car is equipped with a BT05 Bluetooth,

and a Bluetooth APP for remote control is prepared in the data package: bluetooth-V1.95.apk. Bluetooth has 4 pins, only the

correct connection can work, otherwise it will damage the Bluetooth.


68 / 75

Note that one side of the Bluetooth has been marked, and the pin arrangement is as follows:

Because Bluetooth will occupy the RX/TX port, so unplug the Bluetooth before uploading the code!

9.3 code analysis


Open the code file (folder path: 2_ Arduino _Code \ 6_bluetooth_test\6_bluetooth_test.ino)

In the previous course, we have mastered the function code of the car movement, such as the forward function "forward()".

In this lesson, we will focus on understanding the mobile control by using "Switch...case" after Bluetooth receives data, and

first judge whether the connection is successful. And receive the Bluetooth data, and execute the corresponding action after

receiving the corresponding Bluetooth data, such as receiving "F" and executing the forward() function.
69 / 75
70 / 75

10 Integrated Intelligent Control


10.1 Course Introduction
In the fourth lesson, we have mastered how to set up the APP. This lesson mainly understands the programming principle of

Smart Bluetooth control.

10.2 Bluetooth integrated control code analysis


The default is "free control" mode, which is Car_made = 0, and we have three other modes set

When the Bluetooth APP presses the OA button, that is, "1" is sent
71 / 75

At this time, "1" is judged by "Switch...case" in the code, and 1 is saved in the mode variable, at this time "Car_mode = 1".
72 / 75

In the loop loop function, the conditional judgment of the mode control is carried out. When car_mode == 1, the obstacle

avoidance function is executed and the moving speed is set.

The obstacle avoidance function Ultrasonic() is packaged separately


73 / 75

In the same way, you can understand the programming principles of other modes. Receive "2" for follow mode, receive "3"

The "Follow"function
74 / 75

The “tracking ” function

At this point, the study of the entire tutorial has been completed!

You might also like