You are on page 1of 37

ECE 521

MINI PROJECT REPORT GROUP 2:


SMART SANITIZER ROBOT
LECTURER: DR. SHAHRANI BINTI SHAHBUDIN

NAME STUDENT ID

WAN AMIRUL HADIF BIN WAN MOHD NAZALAN 2019405282

AMIRUL RASHIDI BIN JAMIL 2019218854

AIZA JASMIN BINTI GHAZALI 2019291566


TABLE OF CONTENTS

1.0 Introduction 3
1.1 Problem Statement 3
1.2 Objectives 4
1.3 System Specification 4
2.0. Hardware Design 6
2.1. Block Diagram 6
2.2. Description of Component 7
2.2.1. Input 7
2.2.1.1. HC-06 Bluetooth Module 7
2.2.1.2. Ultrasonic Sensor 8
2.2.1.3. Rocker Switch KCD1-101 9
2.2.2. Output 10
2.2.2.1. DC motor 10
2.2.2.2. L293D Motor Driver 11
2.2.2.3. N20 DC gear motor (spray) 12
2.2.2.4. I2C 16x2 LCD 13
2.2.2.5. Light-emitting diode (LED) 14
2.2.3 Processing Unit 14
2.2.3.1 STM32F446RE 14
2.3 Input Output Port for Components Used 16
2.4 Schematic Diagram 17
2.5 Circuit Design 18
3.0 Software Design 19
3.1 Flowchart of System 19
3.2 Operation of System 21
4.0 Results and Discussion 29
4.1 Testing and Debugging 29
4.2 Results obtained 30
5.0 . Conclusion and Recommendation 33
5.1 Conclusion 33
5.2 Recommendation 34
6.0 Reference 35

2
1.0 Introduction

Smart Sanitizer Robot is a machine that can move around a room while spraying sanitizer. This
robot has 2 modes which are roaming mode and control mode. Roaming mode, the robot will
move randomly around the room while avoiding obstacles that are detected by using 3 ultrasonic
sensors. When the front sensors detect an obstacle, it will check the left and then right sensors to
avoid it. Once the robot detects an obstacle, it will stop and spray the sanitizer before deciding to
turn left or right. While in control mode, the user can control the robot movement and spraying
sanitizer by using bluetooth. The command for movement used are ‘w’,’a’,’s’,’d’,’g’ and for
spraying we used ‘e’. This Smart Sanitizer Robot can be used in the house or office to sanitize
the compound.

1.1 Problem Statement

Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute


respiratory syndrome coronavirus 2 (SARS-CoV-2). It was first identified in December
2019 in Wuhan, Hubei, China, and has resulted in an ongoing pandemic.

The virus is mainly transmitted through droplets generated when an infected person
coughs, sneezes, or exhales. The droplets are too heavy to hang in the air so they will
usually fall to the ground or onto surfaces rather than traveling through air over long
distances . Transmission may also occur through smaller droplets (called aerosol) which
makes the lightweight Covid-19 particle to be able to stay suspended in the air and float
for long periods of time. Aerosol transmission can occur during several medical
procedures, as well as in crowded indoor spaces that are poorly ventilated. Infection can
also be contracted by touching a contaminated surface and then touching one's face..

As our surroundings may be an infectious space, disinfecting it is vital to prevent the


spread of COVID-19. It is recommended to use as little manpower as possible for this
task because the cleaning process could result in the human being becoming infected
with the sickness and transmitting the virus to others. This project is to build up a Smart
Sanitizer Robot that disinfects places easily and lessens the possibility of being infected.

3
1.2 Objectives

The objectives of the project are:


1. To design a Smart Sanitizer Robot using STM32F446RE and several types of
input and output using the mbed coding and compiler.
2. To be able to disinfect our surroundings without being exposed to the virus,thus to
help reduce the infection rate of COVID-19.

1.3 System Specification

For this project, we used the STM32F446RE-nucleo board as a microprocessor and


Mbed compiler. Our Smart Sanitizer robot has 2 modes which are manual mode and
roaming mode.We used rocker switch (2-Pin KCD1-101) to alternate between the two
modes.

When we press the rocker switch to manual mode, Red LED will turn on and I2C 16x2
LCD will display “Mode 1: Control Mode”. We control our robot by using the Bluetooth
module through a Bluetooth application installed on our mobile phone which is “Serial
Bluetooth Terminal”. On the application, we will send commands to control the
movement of the robot. There are 5 commands for the direction of the robot that we set,
which are ‘w’, ‘a’, ‘s’, ‘d’ and ‘g’. When we send input ‘w’, the robot will move forward
and the LCD will display “Forward”. Input ‘a’, the robot will turn left and the LCD will
display “Turn Left”. Input ‘d’ , the robot will turn right and the LCD will display “Turn
Right”. Input ‘s’, the robot will move backward and the LCD will display “Reverse”.
Input ‘g’ to stop the robot and the LCD will display “Stop”. Lastly, we set input ‘e’ to
make the robot spray sanitizer for 2 seconds while the LCD displays “spray”.

When we press the rocker switch to roaming mode, Blue LED will turn on and the LCD
will display “Mode 2: Roaming Mode”. We used 3 ultrasonic sensors which are located
in front, left and right to make the robot avoid the obstacles by itself. For example, when
the robot moves forward and detects an obstacle within 25 cm , it will stop and detect if

4
there is any obstacle within 25 cm on the left and right. First it will check if there are no
obstacles within 25 cm on the left it will turn left. If there are obstacles within 25 cm on
the left then it will check for obstacles within 25 cm on the right, if there is no obstacle,
it will turn right. Lastly, when the robot detects obstacles in both left and right direction
it will move backward for a while and turn left. Everytime the robot detects an obstacle
it will spray sanitizer for 2 seconds before proceeding moving in a different direction.

5
2.0. Hardware Design

2.1. Block Diagram

Figure 1 below shows the block diagram for this project, we used 3 inputs which
are HC-06 Bluetooth module, ultrasonic sensors and rocker switch. We used 3 outputs
which are I2C 16x2 LCD, LEDs and DC Motors. Our project used a STM32F446RE
which act as the brain of our Smart Sanitizer Robot to control the inputs and outputs.

Figure 1: Block Diagram

6
2.2. Description of Component
2.2.1. Input
2.2.1.1. HC-06 Bluetooth Module
HC-06 is a Bluetooth module designed for establishing short range wireless data
communication between two microcontrollers or systems. The module works on
Bluetooth 2.0 communication protocol and it can only act as a slave device. This
is the cheapest method for wireless data transmission and more flexible
compared to other methods and it even can transmit files at speed up to 2.1Mb/s.

Figure 2:HC-06 Bluetooth module

Bluetooth protocol Bluetooth V2.0 protocol standard

Power Level Class2(+6dBm)

Band 2.40GHz—2.48GHz, ISM Band

Receiver sensitivity : -85dBm

USB protocol USB v1.1/2.0

Modulation mode Gauss frequency Shift Keying

Safety feature Authentication and encryption

Operating voltage range +3.3V to +6V

Operating temperature range 20ºC to +55ºC

Operating Current 40mA

Table 1: Description for HC-06 Bluetooth Module

7
2.2.1.2. Ultrasonic Sensor
The HC-SR04 Ultrasonic Distance Sensor is a sensor used for detecting the
distance to an object using sonar. The HC-SR04 uses non-contact ultrasound
sonar to measure the distance to an object, and consists of two ultrasonic
transmitters (basically speakers), a receiver, and a control circuit. The
transmitters emit a high frequency ultrasonic sound, which bounce off any
nearby solid objects, and the receiver listens for any return echo. That echo is
then processed by the control circuit to calculate the time difference between the
signal being transmitted and received. This time can subsequently be used, along
with some clever math, to calculate the distance between the sensor and the
reflecting object.

Figure 3: HC-SR04 Ultrasonic Sensor

Input Voltage 5V

Current Draw 20mA (Max)

Digital Output 5V

Digital Output (Low) 0V (Low)

Working Temperature -15°C to 70°C

Sensing Angle 30° Cone

Angle of Effect 15° Cone

Ultrasonic Frequency 40kHz

Range 2cm - 400cm

Table 2: Description for HC-SR04 Ultrasonic Sensor

8
2.2.1.3. Rocker Switch KCD1-101

KCD1-101 miniature rocker switch offer a high switching current in a compact


design. It is a snap-in mounted rocker switch with a high mechanical life in a
rugged nylon 66 housing. They have high quality for long life at heavy loads and
industry-standard mounting dimensions. This rocker switches can be used in a
variety of applications, like water dispensers and extension sockets and so on.

Figure 4: Rocker Switch KCD1-101

Terminal Brass with silver plated

Rating 10A 125VAC/6A 250VAC

Contact Resistance 35mΩ max

Insulation Resistance 100mΩ min (500VDC)

Switch Operation ON-OFF

Operating Temperature -25℃~+85℃

Electrical Life ≥ 10,000 Cycles

Mechanical Life ≥ 100,000 Cycles

Table 3: Description for Switch KCD1-101

9
2.2.2. Output
2.2.2.1. DC motor

As the name implies DC motors are electrical machines which work under DC
power. It converts electrical energy to mechanical energy. Because of several of
its advantages including the high-speed control facilities, DC motors were
universally used in myriad applications. Even then, the DC motors are preferred
in applications starting from toys to electric vehicles. DC motors are low cost
electrical to mechanical converters used in applications. They are preferred over
other motors including stepper motors because of their low cost and speed. The
phenomenon called electromagnetism is the driving principle behind a DC motor.
When a current carrying conductor is placed in the external magnetic field, it will
experience a force proportional to the applied magnetic field.

Figure 5:DC Motor

Operating Voltage 3V to 6V

Recommended/Rated Voltage 5V

Current at No load 120mA (max)

No-load Speed 190 rpm

Car speed (m/minute) 20-48

Motor Size 70mm x 22mm x 18mm

Weight 29 grams

Table 4: Description for DC Motor

10
2.2.2.2. L293D Motor Driver
L293D is a typical Motor driver or Motor Driver IC which allows a DC motor to
drive on either direction. L293D is a 16-pin IC which can control a set of two DC
motors simultaneously in any direction. There are two Enable pins on l293d. Pin 1
and pin 9, for being able to drive the motor, the pin 1 and 9 need to be high. For
driving the motor with the left H-bridge you need to enable pin 1 to high. And for
the right H-Bridge you need to make the pin 9 to high. If any of either pin1 or
pin9 goes low then the motor in the corresponding section will suspend working.
There are 4 input pins for l293d, pin 2,7 on the left and pin 15 ,10. Left input pins
will regulate the rotation of the motor connected across the left side and right
input for the motor on the right hand side. The motors are rotated on the basis of
the inputs provided across the input pins as LOGIC 0 or LOGIC 1

Figure 6: L329D Motor Driver

Vcc2 (Motor) 4.5-36V

Vcc1 (Internal Logic) 5V

Max Current 600mA (per channel)

Max Current (non-repetitive) 1.2A (per Channel)

Vcc1 Max Current 60mA

Operation Temperature 0°C to 70°C.

Table 5: Description for L329D Motor Driver

11
2.2.2.3. N20 DC gear motor (spray)
The N20 Micro Gear 3-6V 48RPM DC Motor (High Torque) is lightweight, high
torque, and low RPM motor. It is equipped with gearbox assembly so as to
increase the torque of the motor. It has a cross-section of 10 × 12 mm, and the
D-shaped gearbox output shaft is 8 mm long and 3 mm in diameter. It has a very
small size so as to fit in complex spaces of small-scale application. This N20
Micro Gear 48 RPM 3-6V DC Motor (High Torque) has small volume, torsion
big, all metal gear, durable, not easy to wear. Great replacement for the rusty or
damaged DC geared speed reduce motor on the machine. Widely used on Boat,
Car, Electric Bicycle, Fan, Home Appliance.We chose this DC motor to operate
our sanitizer spray as it has lower RPM and high torque.

Figure 7: N20 DC Gear Motor

Motor Type Single Shaft

Rated Operating Voltage 5V

No Load Current 30mA

Rated Speed 48 RPM

Operating Voltage 3-6 V

Rated Torque 0.52 kg-cm

Stall Torque 1.8 Kg-Cm

Weight 10g

Shaft Type D-type Single Side

Table 6: Description for N20 DC Gear Motor

12
2.2.2.4. I2C 16x2 LCD

An LCD is an electronic display module that uses liquid crystal to produce a


visible image. The 16×2 LCD display is a very basic module commonly used in
DIYs and circuits. The 16×2 translates o a display 16 characters per line in 2 such
lines. In this LCD each character is displayed in a 5×7 pixel matrix. The I2C 1602
LCD module is a 2 line by 16 character display interfaced to an I2C daughter
board. The I2C interface only requires 2 data connections, +5 VDC and GND.We
also don't have to connect a contrast adjustment potentiometer, because it is
already on the board. LM1602(I2C) gives us control over display backlighting.

Figure 8: I2C 16x2 LCD

Operating voltage 5V

Backlight White

I2C Address (PCF8574) 0x4E

Contrast Adjustable by potentiometer on I2c


interface
Size 80mm x 36mm x 20 mm

Viewing area 66mm x 16mm


Table 7 : Description for I2C 16x2 LCD

13
2.2.2.5. Light-emitting diode (LED)
A light-emitting diode (LED) is a semiconductor device that emits light when an
electric current is passed through it. Light is produced when the particles that
carry the current (known as electrons and holes) combine together within the
semiconductor material.Since light is generated within the solid semiconductor
material, LEDs are described as solid-state devices.

Figure 9 : Light-emitting diode (LED)

2.2.3 Processing Unit


2.2.3.1 STM32F446RE
The STM32F446xC/E devices are based on the high-performance Arm®
Cortex®-M4 32-bit RISC core operating at a frequency of up to 180
MHz. The Cortex-M4 core features a floating point unit (FPU) single
precision supporting all Arm® single-precision data-processing
instructions and data types. It also implements a full set of DSP
instructions and a memory protection unit (MPU) that enhances
application security. The STM32F446xC/E devices incorporate
high-speed embedded memories (Flash memory up to 512 Kbytes, up to
128 Kbytes of SRAM), up to 4 Kbytes of backup SRAM, and an
extensive range of enhanced I/Os and peripherals connected to two APB
buses, two AHB buses and a 32-bit multi-AHB bus matrix. All devices
offer three 12-bit ADCs, two DACs, a low-power RTC, twelve

14
general-purpose 16-bit timers including two PWM timers for motor
control, two general-purpose 32-bit timers.

Figure 10 : STM32F446RE

MICROPROCESSOR STM32F446RE

OPERATING VOLTAGE 1.8-3.6V MAXIMUM

CPU FREQUENCY 180MHz

OPERATING -40~ -100C


TEMPERATURE

12-bit DAC YES

NUMBER OF CHANNELS 2
Table 8 : Description for STM32F446RE

15
2.3 Input Output Port for Components Used

No. PORT CN PIN PIN NAME TYPE I/O COMPONENT

1 A CN10 33 PA10 Input Bluetooth (TX)

2 A CN10 21 PA9 Input Bluetooth (RX)

3 A CN10 13 PA6 Input Rocker Switch

4 C CN7 36 PC1 Input Ultrasonic 1 (echo)

5 C CN10 6 PC5 Input Ultrasonic 2 (echo)

6 C CN7 37 PC3 Input Ultrasonic 3 (echo)

7 C CN7 38 PC0 Output Ultrasonic 1 (Trig)

8 C CN10 34 PC4 Output Ultrasonic 2 (Trig)

9 C CN7 35 PC2 Output Ultrasonic 3 (Trig)

10 B CN10 3 PB8 Output LCD (SCL)

11 B CN10 5 PB9 Output LCD (SDA)

12 C CN10 4 PC6 Output LED 1

13 C CN10 19 PC7 Output LED 2

14 B CN10 27 PB4 Output DC Motor 1 (IN 1)

15 B CN10 29 PB5 Output DC Motor 1 (IN 2)

16 B CN7 21 PB7 Output DC Motor 2 (IN 3)

17 B CN10 17 PB6 Output DC Motor 3 (IN 4)

18 A CN7 28 PA0 Output N20 Motor (IN 1)

19 A CN7 30 PA1 Output N20 Motor (IN 2)


Table 9 : Input Output Port for Components Used

16
2.4 Schematic Diagram

Figure 11 shows the schematic diagram of the system by using STM32f446RE. For input, we
connected the HC-06 bluetooth module to PORT A (PA9,PA10), 3 Ultrasonic sensors are
connected to PORT C (PC0 until PC5), rocker switch is connected to PORT A (PA6). For output,
we connected I2C 16x2 LCD to PORT B (PB8,PB9), 2 LEDs are connected to PORT C
(PC6,PC7), the 2 DC Motors that control the tyre of the robot is connected to PORT B
(PB4-PB7) and lastly N20 motor that is used to operate the spray sanitizer is connected to PORT
A (PA0,PA1).

Figure 11 : Schematic Diagram

17
2.5 Circuit Design

This circuit design connection uses fritzing software to make the designing process easier as
shown in Figure 12. All inputs and outputs used 5V of supply from the nucleo board, except the
motor driver that needs more voltage supply which is 9V.

Figure 12 : Circuit Design

18
3.0 Software Design
3.1 Flowchart of System

Figure 13 : Flowchart

19
Based on Figure 13, the flowchart shown is the overall operation of the project. The system will
start when the power source is ON and begin to set the backlight for the LCD. Then it will read
the input from the rocker switch, if the switch is on, the LCD will display “Mode 1 : Control
Mode” and the Red LED will turn on. For this mode, users need to connect the robot with a
bluetooth application on their smartphone, then only the user can control the movement of the
robot by sending input ‘w’,’a’,’d’,’s’,’g’ and ‘e’. The robot will wait for an input from the
bluetooth module to move. By sending input ‘w’ the robot will move forward while the LCD
displays “Forward”. Input ‘a’ for the robot to turn left while the LCD displays “Turn Left”. Input
‘d’ for the robot to turn right while the LCD displays “Turn Right”. Input ‘s’ for the robot to
move backward while the LCD displays “reverse”.Input ‘g’ for the robot to stop moving while
displays “stop” and lastly input ‘e’ for the robot to spray the sanitizer while the LCD displays
“spray”. When we switch the rocker switch to ‘off’ , the LCD will display “Mode 2 : Roaming
mode” and a blue LED will turn on indicating the robot is in automatic mode. First it will get
input from three ultrasonic sensors which are from front, left and right. The robot will check
front first, if it is clear of any obstacles within 25 cm, it will move forward until it finds an
obstacle, then it will check left first. If there is no obstacle within 25 cm it will stop and spray the
sanitizer before turning left and proceed to move forward. If there is any obstacle on the left then
it will check right, if it is clear of any obstacle within 25 cm then the robot will stop and spray
sanitizer before turning right and proceed to move forward. If all 3 sensors detect an obstacle
within 25 cm, the robot will reverse for a while and turn left before proceeding to move forward.

20
3.2 Operation of System

The system is carried out using the Mbed compiler. The following diagrams below are the
system program of the project and the explanation for the operation of the system.

Figure 14 (a) : Coding

From figure 14 (a), we include 3 library that we used which are “mbed.h” for Mbed Library,
“TextLCD.h” by Simon Ford that is for 16x2 LCD library and “hcsr04.h” by Prabhu Desai for
ultrasonic sensor library. All of the library can be imported from https://os.mbed.com/ .

First of all, we define port PA 9 as TX and port PA 10 as RX which then used to declare the
bluetooth. Mind that TX(PA 9) must be connected to bluetooth’s RX and RX(PA 10) must be
connected to bluetooth’s TX. Then we declare LCD’s SDA as PB 9 and SCL as PB 8, 0x4E
which is the I2C (PCF8674) slaveaddress and LCD type which uses “TextLCD.h” library.
.PCF8574 act as a port extender, to which LCD will be connected.The address of the PCF8574 is
0 1 0 0 A2 A1 A0 R/W. To change the address we are provided with A0, A1 and A2 pins.By
default these three pins are high so the address by default is 01001110 which is 0x4E, thus we
put 0x4E as the slaveaddress. Then we declare PC 6 and PC 7 as output for 2 LEDs by using the
BusOut interface that is used to create a number of DigitalOut pins that can be written as one
value. For Ultrasonic sensors, we need to declare the trigger pin first then the echo pin which
uses “hcsr04.h” library. For the front ultrasonic sensor, we declare PC0 as trigger pin and PC1 as
echo pin, for left ultrasonic sensor, we declare PC4 as trigger pin and PC3 as echo pin, for right
ultrasonic sensor, we declare PC2 as trigger pin and PC3 as echo pin. Then we declare 2 motors

21
that control our robot’s tyre movement as output by using DigitalOut interface that is used to
configure and control a digital output pin which uses the “mbed.h” library. For the left tyre, we
declared PB4 and PB5 as output, for the right tyre we declared PB6 and PB7 as output. Then we
declare PA0 and PA1 as output for N20 DC Motor that is used to operate our spray sanitizer.
Lastly we declare PA6 as input for our rocker switch that is used to switch between control mode
and roaming mode by using DigitalIn interface that is used to read the value of a digital input pin
which uses “mbed.h” library.

Figure 14 (b) : Coding

In Figure 14(b), from line 28 to line 36, we declare all the function prototypes that are used in
our program. Function declaration for function’s name distCheckL,distCheckR and distCheckF
are functions with no parameter with return type int. Function declaration for function’s name
fMotion,bMotion,stopM,lTurn,rTurn and spray are functions with no parameter and no return
value. These functions are for the robot’s movement. Next, we declared lDist,rDist and fDist
with data type unsigned int that are used to store the distance obtained by ultrasonic sensors.

In the main function, we start by turning on the backlight of the LCD and declaring c with data
type char to store our bluetooth’s input as we will be using character ‘w’,’a’,’d’,’s’,’g’ and ‘e’ to
control our robot. In line 46, we used while(1) so that our program will run continuously. Then
we clear LCD’s screen so that when we change between the two modes, the words displayed do
not overlap each other.

22
Figure 14 (c) : Coding

Based on figure 14(c) in line 51, if the rocker switch is off, which is PA6=0, Blue LED will be
turned on which is PC6 and the LCD will display “ Mode 2 : Roaming Mode”. Then we used
while (button==0) which is as long as the rocker switch is off the robot will be in roaming mode.
Line 59 until 61 is to call functions that will start front,left and right ultrasonic sensors and put
the distance obtained in the fDist,lDist and rDist respectively. To decide which direction the
robot needs to move, we used if elseif else statement. Firstly in line 62, if fDist>25 which is if
the obstacle detected is more than 25cm, the robot will move forward.

Figure 14 (d) : Coding

Based on figure 14(d), if the front's ultrasonic sensor detects there is an obstacle within 25cm,
then it checks the left’s distance which is in line 68. If lDist>25 which is if the obstacle detected
on the left is more than 25cm, the robot will execute the following statements from line 70 until
83. In the following lines, the robot will stop and spray the sanitizer, then it will turn left for 1.7s
and stop for 0.5s then it will proceed to move forward if there is no obstacle in front of it. Here,
we just call function stopM() for stopping and function spray() for spraying the sanitizer for 3s.

23
Figure 14 (e) : Coding

Based on figure 14 (e), in line 86, if the front’s and left’s ultrasonic sensor detect an obstacle
within 25cm, then it will check the right’s ultrasonic sensor’s distance. If the obstacle detected is
more than 25cm, then the robot will execute the following statements from line 88 until 101. In
the following statements, the robot will stop and stray the sanitizer, then it will turn right for 1.5s
before stopping for 0.5s. Then if there is no obstacle in front of the robot, it will move forward.

Figure 14 (f) : Coding

Based on figure 14 (f), if all 3 sensors are detecting an obstacle within 25cm, the robot will
execute the following statements from line 105 until 119 which are the robot will stop and spray
the sanitizer, then it will moves backward and then turn left for 1.7s before stopping for 0.5s.
Then the robot will move forward if there is no obstacle in front of it.

24
Figure 14 (g) : Coding

Based on figure 14 (g), if we switch the rocker switch to on which is PA6=1, the robot will be in
control mode which can be controlled by bluetooth. Red LED will turn on which is PC7. in line
129, myled = 2 because we want to turn on PC7 while turn off PC6 (0010). Then the LCD will
display “Mode 1 : Control Mode”. In line 131, while (button==1) which is as long as the rocker
switch is on, the robot will continuously looping from line 133 until 155. Statement in line 133 is
used so that only if there is input to be read from the bluetooth then it will execute the switch
statements. Before that, we put the input from bluetooth into a variable called c by using
bluetooth.getc(). In the switch case, we set input ‘w’ to move forward, so we called the function's
name fMotion to move forward. Similarly to the others input,we just called a function to execute
the movement of the robot. Input ‘s’ to move backward, ‘a’ to turn left, ‘d’ to turn right, ‘g’ to
stop the robot and ‘e’ to spray the sanitizer.

25
Figure 14 (h) : Coding

Based on figure 14 (h), line 162 is the end of the main function. From line 164 to line 169 is the
function definition for function distCheckL which is for left ultrasonic sensor to get distance in
cm and put it in variable lDist which then will be returned to main function. Similarly for right
ultrasonic sensor from line 171 until 176 which will store the right’s distance in rDist. And for
front ultrasonic sensor from line 178 until 183 which will store the front’s distance in fDist.

Figure 14 (i) : Coding

figure 14(i) shows a function definition for function’s name fMotion which is for the robot to
moves forward. First we clear the LCD screen because we want to display “Forward” while the
robot moves forward. Then we set PB4 and PB6 to 1 so that the robot’s tyre motor moves
forward. Then we put wait(2) so that it moves forward for 2s before stopping which we set back
PB4 and PB6 to 0.

26
Figure 14 (j) : Coding
Figure 14 (j) shows the function definition for function’s name bMotion which is for backward
motion and stopM which will stop the robot from moving. In the bMotion function, the LCD will
display “Reverse” and we set PB5 and PB7 to 1 so that the robot’s tyre motor rotates in the
backward motion. Then we put wait(2) so that the robot will move backward for 2s. Then we set
back PB5 and PB7 to 0 to stop the robot. For stopM function, we just simply set PB4, PB5, PB6,
PB7 as 0 so that the robot’s tyre motors are not moving in any direction.

Figure 14 (k) : Coding

Figure 14 (k) shows function definition for function’s name lTurn and rTurn which is for the robot to turn
left and turn right respectively. In the lTurn function, the LCD will display “Turn Left” while the robot
turns left. To turn left we set PB6 to 1 so that the right tyre will move forward and it will result in the
robot to turn left. We set the robot to turn left for only 1.7s before stopping. Similarly for function rTurn,

27
the LCD will display “Turn Right”. Then we set PB4 to 1 so that the left tyre moves forward which will
result in the robot to turn right. We set it to turn right for only 1.5s before stopping.

Figure 14 (l) : Coding


Lastly, figure 14 (l) shows a function definition for function’s name spray which will move the
N20 gear dc motor to spray the sanitizer. First we set the LCD to display “Spray” while the robot
spray the sanitizer. Then we set PA0 to 1 so that the N20 gear dc motor moves and we set it to
move for 3s before stopping.

To summarize the robot’s movement with bluetooth’s input :

Bluetooth’s Robot’s movement PB 4 PB 5 PB 6 PB 7 PA0 PA1


input (left) (left) (right) (right) (spray) (spray)

w Forward 1 0 1 0 0 0

s Backward 0 1 0 1 0 0

a Turn left 0 0 1 0 0 0

d Turn right 1 0 0 0 0 0

g stop 0 0 0 0 0 0

e Spray sanitizer 0 0 0 0 1 0

28
Figure 15 : Serial Bluetooth Terminal app

29
4.0 Results and Discussion
4.1 Testing and Debugging

There are several problems that we encountered while doing this project.

First, we start our mini project by doing some research on the components that can be
used in our project. Then, we buy all the components needed.

Then, we have problems communicating with the Bluetooth module where we send input
and nothing happens. We tried troubleshooting the Bluetooth module by connecting its
Tx pin to its Rx pin. By doing this, if we send any message to the module, it will then
send the message back to us. We found out that the Bluetooth module is working fine. We
troubleshoot again by doing some research on the Internet and we found out that we have
to connect Tx on bluetooth module to Rx on STM32F446RE and vice versa. Then, we
managed to make the Bluetooth module receive our input.

Secondly, we have a problem where the Bluetooth module keeps disconnecting when we
send input to change into Automatic mode. It keeps disconnecting after a few seconds
changing into automatic mode. So, we decided to change modes using a rocker switch
and it worked perfectly.

Thirdly, we encountered an ultrasonic sensor problem where the distance it detects is not
consistent. The ultrasonic detects 0 distance when we try to troubleshoot it. We found out
that the ultrasonic we use is too sensitive and we need to insert the ultrasonic pin to the
breadboard so we can have a more consistent connection. Unfortunately, we don’t have
enough space to put more breadboards in our prototype so we used shorter wires to avoid
the wire to bend constantly as it is the cause of the inconsistency. We also have a problem
where one of our ultrasonic is still giving inconsistent values even after troubleshooting.
For example, we coded the ultrasonic sensor to detect obstacles and display the value of
the obstacle’s distance on our LCD. We noticed that when we put one object as an
obstacle within 25cm, the LCD will display the distance as 25cm for some time and all of
a sudden it displays a large number such as 50-70cm.

30
Next, we had a wiring problem where the jumper from the motor driver to the wire from
the battery holder is not efficient. It is not consistent as the motor sometimes moves and
sometimes doesn't. We connect the wire from the battery holder to our male-to-female
jumper so it probably moves around in the female part of the jumper. We solved it by
wrapping the wire around a male-to-male jumper and we got consistent power supply
after that.

4.2 Results obtained

The coding are able to compile with no error :

Figure 16 : Software simulation result

31
Figure 17 : compile with no error

Prototype result :

Figure 18 : prototype front view

32
Figure 19 : prototype left view

Figure 20 : prototype right view

33
Figure 21 : prototype back view

5.0 . Conclusion and Recommendation

5.1 Conclusion

In conclusion, we successfully completed the project during the time given by the
lecturer. We also have achieved all the objectives of this project. The project that was
given to us was to create a sanitizing robot. First, we started by finding ideas on how the
robot should move to make the sanitizing efficient and controlling it using Bluetooth.
Then, we tried to code it so the robot is working as planned and we created a prototype
for the robot. At the end of the project, we successfully created a robot that has 2 modes
which are automatic and manual mode. For the automatic mode, the robot will move by
itself and avoid any obstacle by using 3 ultrasonic sensors. For the manual mode, we can
control the robot by using a phone application and transmit the signal to the robot using
Bluetooth. The project is coded by using a compatible platform to build the code, which
is a Mbed compiler. From the project, we realized that the Mbed compiler is the most
suitable to build our project with the components we have. The processing unit that we

34
used in this project is STM32F446RE devices. The concept of the robot we created can
also be used in real life. For example, we can use this robot to sanitize a room or
workplace especially in this Covid-19 pandemic situation. In conclusion, the objectives
of this project are achieved through a lot of troubleshooting throughout the process of
creating this robot and the project can run as intended which involves controlling the
robot wirelessly using Bluetooth and making the robot move automatically while
avoiding obstacles and sanitizing.

35
5.2 Recommendation

We identified a number of flaws in the project that can be improved and better prototype
for the robot. The recommendations are :

● Water Level Sensor

By using a water level sensor, we don’t need to check the amount of the
disinfectant left. We can simply combine and code the water level sensor with
LED or LCD so we will know when we need to refill. By using LED, we can turn
on the LED that is specifically used to indicate that there is not much disinfectant
left in the spray bottle. By using LCD, we can write a message to the user that the
spray bottle needs refilling.

● TB6612FNG Motor Driver


TB6612FNG Dual Motor Driver allows us to control the speed of the motor using
its PWM pins and it also has a brake feature. This is because when we cannot
control the motor’s speed, it will result in the robot does not moves straight
forward or straight backward, there will be slight turn in the robot’s movement.

36
6.0 Reference

1. CraftTechEngineer. (2020, December 24). Bluetooth RC Car in Mbed

Platform. Instructables.

https://www.instructables.com/Bluetooth-RC-Car-in-Mbed-Platform/

2. Duan, R. (2017, August 23). Vacuum Buddy | Mbed. Os.Mbed.Com.

https://os.mbed.com/users/rduan8/notebook/vacuum-buddy/

37

You might also like