Sie sind auf Seite 1von 41

Project Report Titled

DENSITY BASED TRAFFIC CONTROL SYSTEM.


Submitted
in partial fulfillment for
the requirements of the diploma in

Electrical Engineering
(Semester V)
By
Mr.Vijay B. Shinde 164120040
Ms.Ruchi R. Parab 164121006
Ms.Rutuja B. Kakad 164121056
Ms.Akanksha M. Jadhav 164121054
Ms.Mayuri J. Chavan 164121006
Ms.Pranjal D. Padwal 164121063
Project Guide : Prof. Suchita Yadwad

Electrical Engineering Department


Veermata Jijabai Technological Institute
Mumbai 400-019
2018-19.

1
CERTIFICATE
This is to certify that the following students
Mr. Vijay B. Shinde 164120040
Ms. Ruchi R. Parab 164121006
Ms. Rutuja B. Kakad 164121056
Ms. Akanksha M. Jadhav 164121054
Ms. Mayuri J. Chavan 164121006
Ms. Pranjal D. Padwal 164121063

have successfully completed and submitted the project entitled


DENSITY BASED TRAFFIC CONTROL SYSTEM.
for the partial fulfillment of

Diploma in Electrical Engineering (Semester V) during the academic year 2018-


2019 as prescribed by VJTI Mumbai.

Prof. Sucheta Yadwad Head Diploma (Electrical).


Guide

Internal Examiner External Examiner

Date:- Seal

Place:- Mumbai

2
ACKNOWLEDGEMENT:

We wish our deep sense of gratitude to our Project Guide Prof. Sucheta
yawad ma’am for his prevalent guidance and useful suggestions and never ending
moral support, which helped us in completing the project in time.
We take opportunity to thanks Prof. Sucheta Yadwad ma’am Head of
Electrical Department and Dr. Dhiren Patel, Director, V.J.T.I. for having us to
carry out this project work.
We are also grateful to our college for providing us INTERNET LAB and its
co-operative employees where we were allowed browsing, learning and hunting for
everything we could think about studying this project. We would like to offer
thanks to the Laboratory Assistant for their co-operation for providing us all the
possible resources.
We thank our beloved parents and friends who always took every chance to
help us in whatever means come forth for the successful completion of this project.

3
ABSTRACT

The project is designed to develop a density based dynamic traffic


signal system. The signal timing changes automatically on sensing the
traffic density at the junction. Traffic congestion is a severe problem in
many major cities across the world and it has become a nightmare for
the commuters in these cities. Conventional traffic light system is based
on fixed time concept allotted to each side of the junction which cannot
be varied as per varying traffic density [1]. Junction timings allotted are
fixed. Sometimes higher traffic density at one side of the junction
demands longer green time as compared to standard allotted time. The
image captured in the traffic signal is processed and converted into
grayscale image then its threshold is calculated based on which the
contour has been drawn in order to calculate the number of vehicles
present in the image. After calculating the number of vehicles we will
came to know in which side the density is high based on which signals
will be allotted for a particular side. Raspberry pi is used as a
microcontroller which provides the signal timing based on the traffic
density.

4
CONTENT
Acknowledgement…………………………………………… 3

Abstract…………………………………………………....... 4

Table of contents……………………………………….……. .5

Part 1: Introduction.

 Introduction……………………………………………....…. 7

Part 2: Methodology

 Block diagram…………………………………………….. 9
 Working……………………………………………………...12

Part 3: Components required

 Arduino uno …………………………………………………14


 LED’s-12(4-red,4-green,4-yellow)…………………..………17
 IR sensors……………………………………………..….......18

Part 4:

 Advantages…………………………………………………..24
 Applications………………………………………………….24

Part 5:

 Conclusion & Future scope………………………………...22


 References…………………………………………………...26
 Appendix………………………………………………...…..27
5
PART 1:
INTRODUCTION

6
INTRODUCTION
In modern life we have to face with many problems one of which is traffic
congestion becoming more serious day after day. It is said that the high volume of
vehicles, the inadequate infrastructure and the irrational distribution of the
development are main reasons for increasing traffic jam. The major cause leading
to traffic congestion is the high number of vehicle which was caused by the
population and the development of economy. Traffic congestion is a condition on
road networks that occurs as use increases, and is characterized by slower speeds,
longer trip times, and increased vehicular queuing. The most common example is
the physical use of roads by vehicles.
When traffic demand is great enough that the interaction between vehicles
slows the speed of the traffic stream, these results in some congestion .As demand
approaches the capacity of a road (or of the intersections along the road), extreme
traffic congestion sets in. When vehicles are fully stopped for periods of time, this
is colloquially known as a traffic jam or traffic snarl-up. Traffic congestion can
lead to drivers becoming frustrated and engaging in road rage. In order to avoid the
congestion in the traffic. In traffic environments, Traffic Sign Recognition (TSR) is
used to regulate traffic signs, warn the driver, and command or prohibit certain
actions. A fast real-time and robust automatic traffic sign detection and recognition
can support and disburden the driver, and thus, significantly increase driving safety
and comfort.
Generally, traffic signs provide the driver various information for safe and
efficient navigation Automatic recognition of traffic signs is, therefore, important
for automated intelligent driving vehicle or driver assistance systems. However,
identification of traffic signs with respect to various natural background viewing
conditions still remains challenging tasks. Real time automatic vision based traffic
light control has been recently the interest of many researchers, due to the frequent
traffic jams at major junctions and its resulting wastage of time. Instead of
depending on information generated by costly sensors, economic situation calls for
using available video cameras in an efficient way for effective traffic congestion
estimation. Thus, given a video sequence, the task of vision based traffic light
control list: 1) analyze image sequences; 2) estimate traffic congestion and 3)
predict the next traffic light interval.

7
PART 2:
METHODOLOGY.

8
BLOCK DIAGRAM:

9
Density Based Traffic Light Control System Circuit
Design:

This circuit consists of 4 IR sensors, arduino uno, 4 traffic lights.

IR transmitter looks like an LED. This IR transmitter always emits IR rays


from it. The operating voltage of this IR transmitter is 2 to 3v. These IR (infra red)
rays are invisible to the human eye. But we can view these IR rays through
camera.IR receiver receives IR rays that are transmitted by IR transmitter.
Normally IR receiver has high resistance in order of mega ohms, when it is
receiving IR rays the resistance is very low. The operating voltage of IR receiver
also 2 to 3V.

We have to place these IR pair in such a way that when we place an obstacle
in front of this IR pair, IR receiver should be able to receive the IR rays. When we
give the power, the transmitted IR rays hit the object and reflect back to the IR
receiver.

Instead of traffic lights, you can use LEDs (RED, GREEN, YELLOW). In
normal traffic system, you have to glow the LEDs on time basis. If the traffic
density is high on any particular path, then glows green LED of that particular path
and glows the red LEDs for remaining paths.

In normal traffic system, we allow the traffic for a time delay of 1 minute for each
path.

10
The above figure shows the IR sensor circuit. Here 330 ohm resistor is used
to drop the voltage otherwise IR transmitter may get damaged. To vary the
obstacle sensing distance, we have used a potentiometer. We have taken the ouput
from transistor collector. This sensor gives the digital output.

11
WORKING:

 Connect 12V battery or adaptor to the development board.

 Switch on the supply.

 Burn the program to the Arduino UNO.

 Connect four IR sensors as shown in figure.

 Arrange all this LED’s same as like traffic lights.

 Arrange one IR sensor for each road.

 Now you can see the normal traffic system based on time basis.

 Now if you place any obstacle in front of any IR sensor, then the system

allows the traffic of that particular path by glowing GREEN light.

 Finally, turn off the board power supply.

12
PART 3:
COMPONENTS
REQUIRED

13
ARDUINO UNO:
The Arduino UNO is an open-source microcontroller board based on the
Microchip ATmega328P microcontroller and developed by Arduino.cc. The board
is equipped with sets of digital and analog input/output (I/O) pins that may be
interfaced to various expansion boards (shields) and other circuits. The board has
14 Digital pins, 6 Analog pins, and programmable with the Arduino IDE
(Integrated Development Environment) via a type B USB cable. It can be powered
by a USB cable or by an external 9 volt battery, though it accepts voltages between
7 and 20 volts.

"Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE) 1.0.[1] The Uno board and version 1.0 of Arduino Software (IDE)
were the reference versions of Arduino, now evolved to newer releases.[4] The
Uno board is the first in a series of USB Arduino boards, and the reference model
for the Arduino platform.[3] The ATmega328 on the Arduino Uno comes
preprogrammed with a bootloader that allows uploading new code to it without the
use of an external hardware programmer.

14
General Pin functions

 LED: There is a built-in LED driven by digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
 VIN: The input voltage to the Arduino board when it's using an external
power source . You can supply voltage through this pin, or, if supplying
voltage via the power jack, access it through this pin.
 5V: This pin outputs a regulated 5V from the regulator on the board. The
board can be supplied with power either from the DC power jack (7 - 20V),
the USB connector (5V), or the VIN pin of the board (7-20V).
 GND: Ground pins.
 IOREF: This pin on the Arduino board provides the voltage reference with
which the microcontroller operates. A properly configured shield can read
the IOREF pin voltage and select the appropriate power source or enable
voltage translators on the outputs to work with the 5V or 3.3V.
 Reset: Typically used to add a reset button to shields which block the one on
the board.

Special Pin Functions

Each of the 14 digital pins and 6 Analog pins on the Uno can be used as an
input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They
operate at 5 volts. Each pin can provide or receive 20 mA as recommended
operating condition and has an internal pull-up resistor (disconnected by default) of
20-50k ohm. A maximum of 40mA is the value that must not be exceeded on any
I/O pin to avoid permanent damage to the microcontroller.The Uno has 6 analog
inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e.
1024 different values). By default they measure from ground to 5 volts, though is it
possible to change the upper end of their range using the AREF pin and the
analogReference() function. In addition, some pins have specialized functions:

15
 Serial: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX)
TTL serial data. These pins are connected to the corresponding pins of
the ATmega8U2 USB-to-TTL Serial chip.
 External Interrupts: pins 2 and 3. These pins can be configured to
trigger an interrupt on a low value, a rising or falling edge, or a change in
value.
 PWM(Pulse Width Modulation) 3, 5, 6, 9, 10, and 11 Can provide 8-bit
PWM output with the analogWrite() function.
 SPI(Serial Peripheral Interface): 10 (SS), 11 (MOSI), 12 (MISO), 13
(SCK). These pins support SPI communication using the SPI library.
 TWI(Two Wire Interface): A4 or SDA pin and A5 or SCL pin. Support
TWI communication using the Wire library.
 AREF(Analog REFerence): Reference voltage for the analog inputs.[7]

Communication

The Arduino/Genuino Uno has a number of facilities for communicating


with a computer, another Arduino/Genuino board, or other microcontrollers. The
ATmega328 provides UART TTL (5V) serial communication, which is available
on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this
serial communication over USB and appears as a virtual com port to software on
the computer. The 16U2 firmware uses the standard USB COM drivers, and no
external driver is needed. However, on Windows, a .inf file is required. The
Arduino Software (IDE) includes a serial monitor which allows simple textual data
to be sent to and from the board. The RX and TX LEDs on the board will flash
when data is being transmitted via the USB-to-serial chip and USB connection to
the computer (but not for serial communication on pins 0 and 1). A SoftwareSerial
library allows serial communication on any of the Uno's digital pins.

16
LED:

A diode is a device which has two active electrodes and two terminals and
allows the current to pass only in single direction. These devices are used to protect
circuits by limiting the voltage and also turn AC into DC. Semiconductors like
silicon and germanium are used to make most of the diodes. Even though they
transmit current in a single direction, the way with which they transmit differs.
There are different kinds of diodes and each type has their own applications
When electric current between the electrodes passes through this diode, light
is produced. In other words, light is generated when sufficient amount of
forwarding current passes through it. In many diodes, this light generated is not
visible as they are frequency levels that do not allow visibility. LEDs are available
in different colors. There are tri-color LEDs which can emit three colors at a time.
Light color depends on the energy gap of the semiconductor used.

17
IR SENSOR:

Infrared radiation (IR) is electromagnetic radiation (EMR) with longer


wavelengths than those of visible light, and is therefore generally invisible to the
human eye (although IR at wavelengths up to 1050 nm from specially pulsed lasers
can be seen by humans under certain conditions. It is sometimes called infrared
light. IR wavelengths extend from the nominal red edge of the visible spectrum at
700 nanometers (frequency 430 THz), to 1 millimeter (300 GHz). Most of the
thermal radiation emitted by objects near room temperature is infrared. Like all
EMR, IR carries radiant energy, and behaves both like a wave and like its quantum
particle, the photon.

IR Sensor Circuit Diagram and Working Principle


An infrared sensor circuit is one of the basic and popular sensor module in
an electronic device. This sensor is analogous to human’s visionary senses, which
can be used to detect obstacles and it is one of the common applications in real
time. This circuit comprises of the following components:

18
• LM358 IC 2 IR transmitter and receiver pair
• Resistors of the range of kilo ohms.
• Variable resistors.
• LED (Light Emitting Diode).

In this project, the transmitter section includes an IR sensor, which transmits


continuous IR rays to be received by an IR receiver module. An IR output terminal
of the receiver varies depending upon its receiving of IR rays. Since this variation
cannot be analyzed as such, therefore this output can be fed to a comparator circuit.
Here an operational amplifier (op-amp) of LM 339 is used as comparator circuit.
When the IR receiver does not receive a signal, the potential at the inverting
input goes higher than that non-inverting input of the comparator IC (LM339).
Thus the output of the comparator goes low, but the LED does not glow. When the
IR receiver module receives signal to the potential at the inverting input goes low.
Thus the output of the comparator (LM 339) goes high and the LED starts glowing.
Resistor R1 (100 ), R2 (10k ) and R3 (330) are used to ensure that minimum 10
mA current passes through the IR LED Devices like Photodiode and normal LEDs
respectively. Resistor VR2 (preset=5k ) is used to adjust the output terminals.
Resistor VR1 (preset=10k ) is used to set the sensitivity of the circuit Diagram.
Read more about IR sensors.

19
PART 4:
ADVANTAGES,
LIMITATIONS &
APPLICATION

20
ADVANTAGES:
 Avoids wastage of time due to the traffic.
 Fully automatic.
 low power consumption.
 It provides the easy access in the traffic light.
 Low cost to design the circuit, maintenance of the circuit is good.
 By using this microcontroller IC we can create many more control to the
appliance.
 We can avoid unnecessary occurrence of traffic jams which causes public
inconvenience.

LIMITATIONS:
 IR sensors sometimes may absorb normal light also. As a result, traffic
system works in improper way.
 IR sensors work only for fewer distances.
 We have to arrange IR sensors in accurate manner otherwise they may not
detect the traffic density.

APPLICATIONS :
 There is no need of traffic inspector at the junction for supervising the traffic
to run smoothly.
 The intelligent work which is done by traffic inspector will be perfectly done
by the microcontroller in the circuit with the help of sensors and the program
which is coded to the microcontroller.

21
PART 4:
CONCLUSION AND
FUTURE SCOPE

22
CONCLUSION AND FUTURE SCOPE:

Continuous growth of population all over the world creates a great challenge
to the transport management systems. The conventional methods are no longer
effective enough for solving complex and challenging transportation management
problems. More economical, more efficient and thus more intelligent methods have
to be developed to deal with these challenging problems. Knowledge from
different research areas is needed for developing these systems. Very often
complex transportation systems require integration of different methods from
different branches of science.
Due to the increased amount of vehicles, it is necessary to take effective
steps in order to control the traffic and hence avoid all types of loses that is caused
due to traffic.
Once we have predicted a high traffic density for a network segment, we can
initiate strategies to avoid this problem. In case of a road network, navigation
systems can try to bypass the critical zone. Furthermore, any traffic control
systems can inform the drivers
This Chapter covers Concluding remarks and future scope about the traffic
jam risk in order to guide them around the critical zone. In order to detect the
traffic different sensors are being used and different techniques are used to
determine the traffic and thus solve the problem related to traffic.
The study aimed at understanding the traffic issues and recommending
improvements to facilitate smoother traffic flows. Population growth, vehicle
ownership, socio-economic characteristics, and public transport facilities were
among the parameters analyzed in the study. Fixed sensors can generate high costs
for setting up and maintaining the required infrastructure. It is also a disadvantage
that such technologies, for practical reasons, have extremely limited local areas of
use, so that a huge number of devices must be installed to determine the traffic
situation in a wide area. Travel times are difficult to estimate with good precision,
especially in urban areas.

23
Over last years, alternative technologies have emerged which seem able to
overcome some of these problems. Collecting real-time traffic data by tracking
vehicle position is one of them. Computer vision presents significant advantage
over other traditional vehicle measurement technologies. Computer vision systems
are more flexible, less invasive, and more precise, more robust, easier to maintain,
produce richer information, do not affect the integrity of the road and offer as an a
added bonus, the possibility to transmit images for human supervision. Several
video image processing systems for traffic density estimation are studied in this
thesis and their advantages and disadvantages are discussed in detail. It has been
identified that the existing methods are not suitable for Indian traffic conditions
which is generally heterogeneous in nature. A new solution is proposed in this
thesis which works very efficiently for Indian traffic and the experimental results
demonstrates the same.
The study identified the following as contributing issues to the traffic
problem:
1. Mixed traffic conditions
2. Encroachment resulting in reduction of capacity of roads
3. Lack of enforcement measures
4. Lack of engineering measures
5. Inefficient and inadequate mass transport system
The broad recommendations emerging out of the study included:
1. Planning should focus on reduction of the traffic load on existing road network
through various travel demand management measures.
2. Emphasis should be placed on mass transport system
3. Concerted efforts are needed in removing encroachments, bottlenecks,
improving
traffic signal, road condition and geometrics at intersections.
4. Video image processing is recommended over other fixed sensors due to its high
efficiency, easy installation and large experience base.
24
5. The proposed solution works well for Indian traffic conditions and can be
quickly
imported into any devices.
Our image sources include highly congested road sections in Bangalore,
Chennai, Mumbai and Delhi where we gathered hours of traffic data in the form of
image sources and collocated traffic video among several cameras. The evaluation
results show our ability to successfully identify the traffic density in highly noisy
images. The proposed system can be used in any traffic management solution
towards real-time traffic density estimation and prediction. Work still remains to
be done in order to improve the computation time and efficient processing of video
frames. Further enhancements are required in vehicle occlusion detection and
classification.

FUTURE WORK:
 We will implement this system for traffic controlling in a 4 lane junction.
 We will update this system with when a pedestrian try to cross the road
during green signal it will turn on an alarm and warn the pedestrian and
traffic police.
 We will update this system with when a vehicle try to move even during red
signal it will turn on an alarm to warn the driver of the vehicle and the traffic

25
REFERENCE:

 www.wikipedia.com
 www.youtube.com
 https://www.circuitdigest.com
 https://electronicshub.com
 https://electronicsforu.com
 https://arduino.cc

26
APPENDIX:

Project code:-

int one = A0;


int two = A1;
int three = A2;
int four = A3; //takes sensor inputs

int oneG = 2;
int oneY = 3;
int oneR = 4;
int twoG = 5;
int twoY = 6;
int twoR = 7;
int threeG = 8;
int threeY = 9;
int threeR = 10;
int fourG = 11;
int fourY = 12;
int fourR = 13; //signal lights

//int one_value = 0;
//int two_value = 0;
//int three_value = 0;

27
//int four_value = 0;
int t =3;
int baseline = 100;
int baseline2 = 158;
int baseline3 = 140;
int p1 = 0;
int p2 = 0;
int p3 = 0;
int p4 = 0;

int pre1 = 0;
int pre2 = 0;
int pre3 = 0;
int pre4 = 0;

int max1=0;
int status1=0; //Check whether signal is on or off
int dum_max=0;

int g1=0;
int g2=0;
int g3=0;
int g4=0;

float one_count = 0;

28
float two_count = 0;
float three_count = 0;
float four_count = 0;

void setup() {
pinMode(oneG,OUTPUT);
pinMode(oneY,OUTPUT);
pinMode(oneR,OUTPUT);
pinMode(twoG,OUTPUT);
pinMode(twoY,OUTPUT);
pinMode(twoR,OUTPUT);
pinMode(threeG,OUTPUT);
pinMode(threeY,OUTPUT);
pinMode(threeR,OUTPUT);
pinMode(fourG,OUTPUT);
pinMode(fourY,OUTPUT);
pinMode(fourR,OUTPUT);

Serial.begin(9600);
}

void loop() {
// read the value from the sensor:

29
pre1 = analogRead(one);
pre2 = analogRead(two);
pre3 = analogRead(three);
pre4 = analogRead(four);

if(p1>baseline && pre1<baseline && g1!=1)


{
one_count++;
}
p1 = pre1;

if(p2>baseline && pre2<baseline && g2 !=1)


{
two_count++;
}
p2 = pre2;

if(p3>baseline2 && pre3<baseline2 && g3!=1)


{
three_count++;
}
p3 = pre3;

if(p4>baseline3 && pre4<baseline3 && g4!=1)


{

30
four_count++;
}
p4 = pre4;

if((one_count>=two_count) && (one_count>=three_count) &&


(one_count>=four_count))
{ max1=1;}
else if((two_count>=three_count) && (two_count>=four_count) &&
(two_count>one_count))
{ max1=2;}
else if((three_count>=four_count) && (three_count>two_count) &&
(three_count>one_count))
{ max1=3;}
else if((four_count>three_count) && (four_count>two_count) &&
(four_count>one_count))
{ max1=4;}

if(status1==0)
{ dum_max=max1; }

if((one_count<=0)&&(two_count<=0)&&(three_count<=0)&&(four_count<=0))
{
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, LOW);
digitalWrite(twoG, LOW);
digitalWrite(twoY, LOW);
31
digitalWrite(twoR, LOW);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, LOW);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, LOW);
}
else{

if(dum_max==1)
{ status1=1;
g1=1;
digitalWrite(oneG, HIGH);
digitalWrite(oneY, LOW);
digitalWrite(oneR, LOW);

if((two_count>=three_count) && (two_count>=four_count))


{
digitalWrite(twoG, LOW);
digitalWrite(twoY, HIGH);
digitalWrite(twoR, LOW);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);

32
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((three_count>two_count) && (three_count>=four_count))
{
digitalWrite(twoG, LOW);
digitalWrite(twoY, LOW);
digitalWrite(twoR, HIGH);
digitalWrite(threeG, LOW);
digitalWrite(threeY, HIGH);
digitalWrite(threeR, LOW);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((four_count>three_count) && (four_count>two_count))
{
digitalWrite(twoG, LOW);
digitalWrite(twoY, LOW);
digitalWrite(twoR, HIGH);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);
digitalWrite(fourG, LOW);

33
digitalWrite(fourY, HIGH);
digitalWrite(fourR, LOW);
}

one_count = one_count - t*0.01;

if(one_count<=0)
{
status1=0;
g1=0;
}
}

else if(dum_max==2)
{ status1=1;
g2=1;
digitalWrite(twoG, HIGH);
digitalWrite(twoY, LOW);
digitalWrite(twoR, LOW);

if((one_count>=three_count) && (one_count>four_count))


{
digitalWrite(oneG, LOW);
digitalWrite(oneY, HIGH);

34
digitalWrite(oneR, LOW);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((three_count>=four_count) && (three_count>one_count))
{
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);
digitalWrite(threeG, LOW);
digitalWrite(threeY, HIGH);
digitalWrite(threeR, LOW);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((four_count>one_count) && (four_count>three_count))
{
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);

35
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);
digitalWrite(fourG, LOW);
digitalWrite(fourY, HIGH);
digitalWrite(fourR, LOW);
}
two_count = two_count - t*0.01;
if(two_count<=0)
{
status1=0;
g2=0;
}
}

else if(dum_max==3)
{ status1=1;
g3=1;
digitalWrite(threeG, HIGH);
digitalWrite(threeY, LOW);
digitalWrite(threeR, LOW);

if((one_count>=two_count) && (one_count>=four_count))


{
digitalWrite(twoG, LOW);

36
digitalWrite(twoY, LOW);
digitalWrite(twoR, HIGH);
digitalWrite(oneG, LOW);
digitalWrite(oneY, HIGH);
digitalWrite(oneR, LOW);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((two_count>=four_count) && (two_count>one_count))
{
digitalWrite(twoG, LOW);
digitalWrite(twoY, HIGH);
digitalWrite(twoR, LOW);
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);
digitalWrite(fourG, LOW);
digitalWrite(fourY, LOW);
digitalWrite(fourR, HIGH);
}
else if((four_count>two_count) && (four_count>one_count))
{
digitalWrite(twoG, LOW);
digitalWrite(twoY, LOW);

37
digitalWrite(twoR, HIGH);
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);
digitalWrite(fourG, LOW);
digitalWrite(fourY, HIGH);
digitalWrite(fourR, LOW);
}

three_count = three_count - t*0.01;


if(three_count<=0)
{
status1=0;
g3=0;
}
}

else if(dum_max==4)
{ status1=1;
g4=1;
digitalWrite(fourG, HIGH);
digitalWrite(fourY, LOW);
digitalWrite(fourR, LOW);
if((one_count>=two_count) && (one_count>=three_count))
{

38
digitalWrite(twoG, LOW);
digitalWrite(twoY, LOW);
digitalWrite(twoR, HIGH);
digitalWrite(oneG, LOW);
digitalWrite(oneY, HIGH);
digitalWrite(oneR, LOW);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);
}
else if((two_count>one_count) && (two_count>=three_count))
{
digitalWrite(twoG, LOW);
digitalWrite(twoY, HIGH);
digitalWrite(twoR, LOW);
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);
digitalWrite(threeG, LOW);
digitalWrite(threeY, LOW);
digitalWrite(threeR, HIGH);
}
else if((three_count>two_count) && (three_count>one_count))
{
digitalWrite(twoG, LOW);

39
digitalWrite(twoY, LOW);
digitalWrite(twoR, HIGH);
digitalWrite(oneG, LOW);
digitalWrite(oneY, LOW);
digitalWrite(oneR, HIGH);
digitalWrite(threeG, LOW);
digitalWrite(threeY, HIGH);
digitalWrite(threeR, LOW);
}
four_count = four_count - t*0.01;
if(four_count<=0)
{
status1=0;
g4=0;
}
}
}
Serial.print(pre1);
Serial.print("\t");
Serial.print(pre2);
Serial.print("\t");
Serial.print(pre3);
Serial.print("\t");
Serial.print(pre4);
Serial.print("\t");

40
Serial.print(one_count);
Serial.print("\t");
Serial.print(two_count);
Serial.print("\t");
Serial.print(three_count);
Serial.print("\t");
Serial.print(four_count);
Serial.print("\n");

delay(10);
}

41

Das könnte Ihnen auch gefallen