1. Trang chủ
  2. » Kinh Doanh - Tiếp Thị

Project Iot102 Bluetooth-Controlled Traffic Light.pdf

18 57 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Bluetooth-Controlled Traffic Light
Tác giả Nguyễn Cảnh Tân, Nguyễn Như Tài, Trương Nhật Anh, Trần Lệnh Quốc Huy
Thể loại project
Định dạng
Số trang 18
Dung lượng 1,08 MB

Nội dung

The Bluetooth module facilitates wireless communication between the traffic light controller and the mobile application, which serves as a user interface for monitoring and controlling t

Trang 1

PROJECT IOT102

Bluetooth-controlled traffic light

Group member

Trương Nhật Anh SE184905 Trần Lệnh Quốc Huy SE183878

Trang 2

I Introduction about this project 3

II About hardware 5

1 Components 5

2 Properties of components 5

3 Schematic design 5

III About software 5

1 Requirement analysis 5

2 Flowchart 5

3 Source code 5

IV Implementation and Inspection 5

V Conclusion 6

Trang 3

I Introduction about this project

The Bluetooth-controlled traffic light for junction and pedestrian project is an innovative solution that leverages Internet of Things (IoT) technology to enhance traffic management and improve pedestrian safety at intersections With the rapid urbanization and increasing vehicular traffic, there is a growing need for efficient traffic control systems that can adapt to changing conditions in real-time

Traditionally, traffic lights operate on fixed timers, resulting in inefficient traffic flow and potentially hazardous situations for pedestrians This project aims to address these challenges by

implementing a smart traffic light system that utilizes Bluetooth technology for communication and control

The main objective of this project is to design and develop a traffic light system that can dynamically adjust signal timings based on traffic conditions and prioritize pedestrian safety By incorporating Bluetooth connectivity, the system enables real-time communication between vehicles and traffic lights, allowing for efficient coordination and traffic flow optimization

The Bluetooth-controlled traffic light system consists of three main components: the traffic light controller, the Bluetooth module, and the mobile application The traffic light controller is responsible for managing the signal timings and coordinating the flow of vehicles and pedestrians The Bluetooth module facilitates wireless communication between the traffic light controller and the mobile application, which serves as a user interface for monitoring and controlling the traffic lights

The mobile application provides a user-friendly interface where authorized personnel, such as traffic operators or city officials, can

Trang 4

remotely monitor the traffic conditions and manually control the signal timings if necessary

Overall, this project aims to improve traffic management efficiency, reduce congestion, and enhance pedestrian safety by implementing a Bluetooth-controlled traffic light system By leveraging IoT

technology, this solution has the potential to revolutionize the way traffic is controlled at junctions and provide a safer and more efficient transportation experience for both drivers and pedestrians

II About hardware

1 Components

● Arduino UNO board

● Red, yellow and green LEDs

● Breadboard

● Module bluetooth HC-05

● Smartphone

● Ressitor

2 Properties of components

a Arduino UNO board:

● Microcontroller: ATmega328P

● Operating Voltage: 5V

● Digital I/O Pins: 14 (of which 6 can provide PWM output)

● Analog Input Pins: 6

● Flash Memory: 32KB (ATmega328P), of which 0.5KB

is used by the bootloader

● SRAM: 2KB

● EEPROM: 1KB

● Clock Speed: 16 MHz

● Interface: USB, I2C, SPI, UART

Trang 5

● Quantity: 1

b LEDs (Light Emitting Diodes):

● Emit light when a current flows through them

● Different colors available ( red, green, white, yellow)

● Voltage drop across an LED typically around 1.8-3.3V

● Current requirement varies based on the specific LED

● Quantity: 2 red, 2 green, 2 white, 2 yellow

c Breadboard:

● Used for prototyping and connecting electronic components

● Contains a grid of holes connected by metal strips

● No need for soldering as components can be inserted and connected easily

● Quantity: 1

d Bluetooth module HC-05:

● Bluetooth version: 2.0+EDR

● Operating Voltage: 3.3V

● Communication interface: UART (Universal Asynchronous Receiver-Transmitter)

● Range: Typically around 10 meters

● Supports Bluetooth serial communication with other devices (e.g., smartphones, computers)

● Quantity: 1

e Smartphone:

● A mobile device with advanced computing

capabilities

● Typically runs on iOS (Apple) or Android (Google) operating systems

● Can be used for various purposes, including

controlling and monitoring the Bluetooth-controlled traffic light system through a mobile application

● Quantity: 1

Trang 6

f Resistor:

● Passive electronic component that restricts the flow of electric current

● Used to limit current in an LED circuit to prevent damage

● Resistance is 220-ohms (Ω)

● Value depends on the specific LED and desired current flow

● Quantity: 6

3. Schematic design

Trang 7

III About software

1. Requirement analysis

A.Functional Requirements:

● Traffic Light Control:

- The system control two sets of traffic lights, each with red, yellow,

and green lights.

Traffic lights for each set are controlledindependently

The system switch between different states (red, yellow, green) according to a predefined sequence in source code

● Pedestrian Signal:

The system include pedestrian signals synchronized with each traffic light set

Pedestrian signals indicate when it is safe for pedestrians to cross in each direction (when the red traffic light of the other set turns off)

● Bluetooth Communication:

The system communicate with external mobile device via Bluetooth

It receive commands from a remote device for manual control

● Automatic Mode:

The system have an automatic mode where it controls the traffic lights without external input

Automatic mode cycle through predefined traffic light sequences

● Manual Mode:

Trang 8

The system have a manual mode accessible via Bluetooth

commands

Manual mode allow users to override automatic control and set the state of each traffic light individually

B.Non-Functional Requirements:

● Reliability:

The system operate reliably under normal conditions

● Safety:

Pedestrian signals are synchronized with traffic lights to prevent conflicts between vehicle and pedestrian traffic

Traffic light transitions are smooth and predictable to avoid confusion for drivers and pedestrians

● Usability:

The Bluetooth interface is user-friendly, providing clear instructions for manual control

//The system provide feedback to the user confirming execution of commands

● Performance:

The system respond to Bluetooth commands within a reasonable timeframe

Traffic light transitions occur without noticeable delays to maintain traffic flow efficiency

● Scalability:

The system architecture is scalable to accommodate potential future expansions or modifications

It is possible to add additional features or integrate with other systems without significant redesign

Trang 9

● Power Consumption:

The system is designed to minimize power consumption to prolong battery life if applicable

It includes sleep modes or low-power states when not actively controlling traffic lights

2 Flowchart

Trang 12

3. Source code

#include <SoftwareSerial.h>

// Khai báo chân được sử dụng cho đèn giao thông

const int red1Pin = 13;

const int yellow1Pin = 12;

const int green1Pin = 11;

const int red2Pin = 8;

const int yellow2Pin = 9;

const int green2Pin = 10;

const int white1Pin = 6;

const int white2Pin = 7;

// Khai báo chân được sử dụng cho LED báo hiệu cho người đi bộ const int pedes1Pin = 7;

const int pedes2Pin = 6;

char incomingByte; // Biến lưu trữ dữ liệu nhận được từ Bluetooth // Khai báo địa chỉ Bluetooth

SoftwareSerial bt(0, 1); // RX, TX

void setup() {

// Thiết lập chân là OUTPUT

pinMode(red1Pin, OUTPUT);

pinMode(yellow1Pin, OUTPUT);

pinMode(green1Pin, OUTPUT);

pinMode(red2Pin, OUTPUT);

pinMode(yellow2Pin, OUTPUT);

pinMode(green2Pin, OUTPUT);

pinMode(pedes1Pin, OUTPUT);

pinMode(pedes2Pin, OUTPUT);

Serial.begin(9600);

// Bắt đầu giao tiếp Bluetooth

bt.begin(9600);

}

void autoTrafficLight() {

digitalWrite(green1Pin, LOW);

digitalWrite(yellow1Pin, HIGH);

digitalWrite(red1Pin, LOW);

digitalWrite(green2Pin, LOW);

digitalWrite(yellow2Pin, HIGH);

digitalWrite(red2Pin, LOW);

digitalWrite(white1Pin, LOW);

Trang 13

digitalWrite(white2Pin, LOW);

delay(3000);

// Đèn red1 và green2 sáng, đèn white2 sáng, đèn yellow1 và yellow2 tắt, đèn white1 tắt

digitalWrite(green1Pin, LOW);

digitalWrite(yellow1Pin, LOW);

digitalWrite(red1Pin, HIGH);

digitalWrite(white1Pin, LOW);

digitalWrite(green2Pin, HIGH);

digitalWrite(yellow2Pin, LOW);

digitalWrite(red2Pin, LOW);

digitalWrite(white2Pin, HIGH);

delay(3000);

// Đèn green1 sáng, đèn white1 sáng, đèn red2 tắt, đèn white2 tắt digitalWrite(green1Pin, HIGH);

digitalWrite(yellow1Pin, LOW);

digitalWrite(red1Pin, LOW);

digitalWrite(white1Pin, HIGH);

digitalWrite(green2Pin, LOW);

digitalWrite(yellow2Pin, LOW);

digitalWrite(red2Pin, HIGH);

digitalWrite(white2Pin, LOW);

delay(3000);

}

void loop() {

if (Serial.available() > 0) {

incomingByte = Serial.read(); // Đọc dữ liệu nhận được từ Bluetooth

if (incomingByte == '1') {

// Bật đèn đỏ và tắt các đèn khác cho đèn giao thông thứ nhất digitalWrite(red1Pin, HIGH);

digitalWrite(yellow1Pin, LOW);

digitalWrite(green1Pin, LOW);

// Bật đèn xanh và tắt các đèn khác cho đèn giao thông thứ hai digitalWrite(red2Pin, LOW);

digitalWrite(yellow2Pin, LOW);

digitalWrite(green2Pin, HIGH);

digitalWrite(pedes1Pin, HIGH);

Trang 14

digitalWrite(pedes2Pin, LOW);

} else if (incomingByte == '2') {

// Bật đèn vàng và tắt các đèn khác cho đèn giao thông thứ nhất digitalWrite(red1Pin, LOW);

digitalWrite(yellow1Pin, HIGH);

digitalWrite(green1Pin, LOW);

// Bật đèn vàng và tắt các đèn khác cho đèn giao thông thứ hai digitalWrite(red2Pin, LOW);

digitalWrite(yellow2Pin, HIGH);

digitalWrite(green2Pin, LOW);

// Tắt đèn pedes1Pin cho người đi bộ và bật đèn pedes2Pin digitalWrite(pedes1Pin, HIGH);

digitalWrite(pedes2Pin, HIGH);

} else if (incomingByte == '3') {

// Bật đèn pedes1Pin cho người đi bộ và tắt đèn pedes2Pin // Tắt đèn vàng và tắt các đèn khác cho đèn giao thông thứ nhất digitalWrite(red1Pin, LOW);

digitalWrite(yellow1Pin, LOW);

digitalWrite(green1Pin, HIGH);

// Bật đèn đỏ và tắt các đèn khác cho đèn giao thông thứ hai digitalWrite(red2Pin, HIGH);

digitalWrite(yellow2Pin, LOW);

digitalWrite(green2Pin, LOW);

// Bật đèn pedes1Pin cho người đi bộ và tắt đèn pedes2Pin digitalWrite(pedes1Pin, LOW);

digitalWrite(pedes2Pin, HIGH);

}

while (incomingByte == '4') {

while (true) {

int incomingByte2 = Serial.read();

//Doc them 1 lan lenh tu button de dung vong lap, neu ko an gi thi gia tri mac dinh incomingByte2 = -1, neu chon lenh khac -> incomingByte2 khac -1 -> chay het lenh 1 vong while, vong lap nay se dung

if (incomingByte2 != -1) break;

//auto

autoTrafficLight();

}

//dung` vong lap to khi vong lap nho dung` de nhan lenh khac

Trang 15

}

}

}

IV Implementation and Inspection

A.Implementation

● Header and Libraries:

The program starts by including the SoftwareSerial.h library for software serial communication

● Pin Declarations:

Pins for traffic lights and pedestrian signals are declared as constants

SoftwareSerial is initialized for Bluetooth communication

● Setup:

Sets the pins as outputs for LEDs

Begins serial communication for debugging and initializes Bluetooth

● Auto Traffic Light Function:

Defines a function to run the traffic light sequence automatically

It sets different combinations of pins to control the traffic lights and pedestrian signals, simulating a traffic light sequence

● Loop:

Checks for available data from Bluetooth

Reads incoming data from Bluetooth

Based on the received data, it controls the traffic lights:

Trang 16

'1' sets one set of traffic lights for vehicle traffic.

'2' sets another set of traffic lights for vehicle traffic and activates pedestrian signal

'3' activates pedestrian signal for crossing

'4' initiates an automatic traffic light sequence

It exits the automatic sequence loop when receiving any other command

B.Inspection

● Bluetooth Communication:

The program uses SoftwareSerial for Bluetooth communication, which

is suitable for Arduino boards lacking hardware serial ports

● Traffic Light Logic:

The logic for controlling the traffic lights straightforward and

understandable

The sequence is controlled based on incoming commands from Bluetooth

● Pedestrian Signals:

Pedestrian signals are incorporated into the traffic light sequence, ensuring safety for pedestrians

● Automatic Mode:

The automatic traffic light sequence provides convenience, but it might

be improved by incorporating sensors to detect vehicle and pedestrian traffic for a more dynamic operation

● Code Organization:

The code could be organized into more functions to improve

readability and maintainability

Trang 17

● Comments and Documentation:

The program contains comments, which help in understanding the functionality of different parts

● Hardware Considerations:

The program assumes the hardware setup matches the pin

configurations defined Ensure that the physical connections align with the pin assignments in The program

● Testing:

Before deploying this system, thorough testing is necessary to ensure its reliability and safety, especially in real-world traffic scenarios

V Conclusion

In conclusion, the Bluetooth-controlled traffic light project offers several advantages in terms of flexibility, energy efficiency, smart management, and ease of installation and scalability By enabling remote control of traffic signals through Bluetooth connectivity, the project allows for dynamic control of traffic flow, making it useful in densely populated areas, special events, or emergency situations The system can be designed to

automatically adjust traffic signals based on real-time data and other parameters, reducing waiting times and saving energy by activating lights only when necessary

Furthermore, the collected data from the traffic lights can be utilized for traffic analysis, pattern recognition, and traffic flow optimization, leading to improved traffic efficiency and

congestion reduction The use of Bluetooth connectivity

simplifies the installation process and facilitates system

Trang 18

expansion without the need for complex wiring Overall, the Bluetooth-controlled traffic light project presents a promising solution for traffic management Continued research and development efforts are necessary to realize the project and ensure the compatibility and safety of the system

Ngày đăng: 13/05/2024, 14:54

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w