Graduation Project of the Internet of Things: Intelligent Obstacle Avoidance and Sweeping Robot Based on Single Chip Microcomputer

0 Preface

🔥 In the past two years, the requirements and difficulty of graduation project and graduation defense have been continuously increasing. The traditional graduation project lacks innovation and highlights, and often fails to meet the requirements of graduation defense. In the past two years, students have been telling seniors to do it themselves The project system does not meet the teacher's requirements.

In order for everyone to pass the graduation project smoothly and with the least amount of energy, the seniors share high-quality graduation design projects. What I want to share today is

🚩 Intelligent obstacle avoidance sweeping robot based on single chip microcomputer

🥇 Seniors here give a comprehensive score for a topic (full score for each item is 5 points)

  • Difficulty factor: 3 points
  • Workload: 3 points
  • Innovation point: 4 points

🧿 Topic selection guidance, project sharing:

1 Introduction

This project makes a single-chip microcomputer-based vacuum cleaner, floor cleaning robot, which is not only simple to make, but also much lower cost than commercial products on the market. On top of that, the robot will be equipped with ultrasonic sensors and infrared proximity sensors. Ultrasonic sensors will enable the robot to avoid obstacles so it can move freely, while proximity sensors will help it avoid falling down stairs.

2 main components

  • 51 MCU
  • HC-SR04 ultrasonic module
  • L293D Motor Driver
  • 5 volt N20 motor and mounting bracket
  • N20 motor wheel
  • switch
  • LM7805 Voltage Regulator
  • 7.4V lithium-ion battery
  • Infrared Sensor Module
  • Universal board
  • Universal Portable Vacuum Cleaner

3 Realize the effect

4 Hardware Design

HC-SR04 Ultrasonic Sensor Module

To detect obstacles, we use the common HC-SR04 ultrasonic distance sensor, or you can call it an obstacle avoidance sensor. The working principle is very simple, first, the transmitter module sends an ultrasonic wave, it travels through the air, hits an obstacle, and bounces back, the receiver receives the wave. By counting time using Arduino we can determine distance. In our previous article on the Arduino Based Ultrasonic Distance Sensor, we discussed in great depth how this sensor works.

module parameters

(1) Main electrical parameters of the module

  • Use voltage: DC-5V
  • Quiescent current: less than 2mA
  • Level output: high 5V
  • Level output: bottom 0V
  • Induction angle: no more than 15 degrees
  • Detection distance: 2cm-450cm
  • High precision up to 0.2cm

(2) Module pins
The ultrasonic module has 4 pins, which are Vcc, Trig (control terminal), Echo (receiving terminal), and GND; where VCC and GND are connected to a 5V power supply, Trig (control terminal) controls the ultrasonic signal sent, and Echo (receiving terminal) ) to receive the reflected ultrasonic signal. The module is shown in the figure

Infrared Sensors for Stair Detection

In order for the robot to detect the stairs and prevent itself from falling, we use infrared sensors. We connect the IR sensor to the Arduino board. The working of the infrared proximity sensor is very simple, it has an infrared LED and a photodiode, the infrared LED emits infrared light, if an obstacle comes in front of this emitted light, it is reflected, and the reflected light is detected by the photodiode . But the voltage generated by the reflection will be very low. To increase it, we can use an op amp comparator, we can amplify and get the output. The IR module has three pins - Vcc, Ground and Output. Normally, the output goes low when there is an obstacle in front of the sensor. So, we can use it to detect the floor. If at some point, we detect a high level from the sensor, we can stop the robot and turn it back to prevent it from falling down the stairs.

schematic diagram

We use three ultrasonic sensors to detect obstacles. So we need to connect all the grounds of the ultrasonic sensor and connect them to a common ground. Also, connect all three VCCs of the sensor and connect them to the common VCC pin. Next, connect the Trig and Echo pins to the Arduino's PWM pins. We also connect the VCC of the infrared module to 5V, the GND to the ground pin of the Arduino, and the output pin of the infrared sensor module to the digital pin D2 of the Arduino. For the motor driver we connect the two enable pins to 5v and the driver voltage pin to 5V since we are using a 5V motor. Arduino, ultrasonic module, motor driver and motor all work on 5V, higher voltage will damage it, we are using 7.4 volt battery which is converted to 5 volt using LM7805 regulator.

5 Software Description

This Arduino code is similar to the Arduino-based Ultrasonic Distance Sensor code, the only change is the addition of floor detection.
Define the Trig pins and Echo pins that are connected to the Arduino board. In this article, we have three Trig pins and three Echo pins. Note that 1 indicates the left sensor, 2 indicates the front sensor, and 3 indicates the right sensor.

const  int trigPin1 = 3;
const int echoPin1 = 5; 
const int trigPin2 = 6;
const int echoPin2 =9; 
const int trigPin3 = 10;
const int echoPin3 = 11;

Then, we define all the variables related to distance, they are all of type (int) variables, for the duration, we choose to use (long). Again, we have three of each.

long duration1;
 long duration2;
 long duration3;
int distanceleft;
int distancefront;
int distanceright;

Next, in the setup() function, we need to use the pinModes() function to make all the relevant pins as input or output. To send ultrasonic waves from the module, we need to set Trig pins to high level, all Trig pins should be defined as OUTPUT. In order to receive echo, we need to read the status of Echo pins, all Echo pins should be defined as INPUT. Also, we enable the serial monitor for troubleshooting

pinMode(trigPin1, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin1, INPUT); 
pinMode(echoPin2, INPUT);
pinMode(echoPin3, INPUT);

These digital pins below are defined as outputs of the motor driver.

pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, OUTPUT);

After taking distance from each sensor, we can control the motors and thus the robot's movement with the help of if statements. It's very simple, first, we give the obstacle distance a value of 15 cm (change this value as needed). We then give conditions based on that value. For example, when an obstacle comes in front of the left sensor (i.e. the distance from the left sensor should be less than or equal to 15 cm) and the other two distances are high (which means there is no obstacle in front of this sensor), then use the digital write function , we can drive the motor to the right.

if ((distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15))

The following code is used to move the robot to the right:

 digitalWrite(4, HIGH);
 digitalWrite(7, LOW);
 digitalWrite(8, HIGH);
 digitalWrite(12, LOW);

If the robot detects that no stairs have been encountered, the value changes to 1 and the robot moves left. After turning left, the value of 'a' changes from 1 to 0.

 if ((a==1) &&(s==LOW) ||(s==LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s== LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s==LOW) && (distanceleft <= 15 && distancefront > 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15))
    digitalWrite(4, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(12, HIGH);

The following code is used to move the robot to the left:

 if ((s==LOW)&&(distanceleft > 15 && distancefront <= 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront > 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
    digitalWrite(4, LOW);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(12, LOW);

6 last

contains content

🧿 Project sharing:

Tags: Single-Chip Microcomputer

Posted by Hagaroo on Tue, 04 Apr 2023 05:42:14 +0930