You are on page 1of 49

1.

1 Overview
Traffic research has the goal to optimize traffic flow of people and goods. As the number
of road users constantly increases, and resources provided by current infrastructures are
limited, intelligent control of traffic will become a very important issue in the future.
However, some limitations to the usage of intelligent traffic control exist. Avoiding traffic
jams for example is thought to be beneficial to both environment and economy, but
improved traffic-flow may also lead to an increase in demand. There are several models
for traffic simulation. In our research we focus on optimization of traffic light controllers
in a city using IR sensor and control traffic using ATMEGA 08 microcontroller.
The traffic control system based on vehicle density calculation tries to reduce possibilities
of traffic jams, caused by traffic lights. The system contains three IR transmitter and IR
receiver for traffic density measurement which are mounted on the either sides of roads
respectively. The IR system gets activated whenever any vehicle passes on road between
IR sensors. When one sensor will be ON at that time density will be less when two
sensors will be ON at that traffic density is medium when all 3 sensor will be ON at that
time density will be high. Microcontroller controls the IR system and counts number of
vehicles passing on road. Based on vehicle density calculation, the microcontroller takes
decision and updates the traffic light delays as a result. The traffic light is situated at a
certain distance from the IR system. Thus based on vehicle density calculation,
microcontroller defines different ranges for traffic light delays and update.
Also we use GPS technology to give accidental information about the vehicle. When
traffic accidents occur, the system immediately notifies the location of accident to
emergency personnel like ambulance by use of GPS technology. Also the system have
facility to emergency vehicle detection system like ambulance, police etc. When an
emergency car comes on the signal and number of vehicles will be available in front of
the emergency vehicle. In this situation, the system will detect the emergency car, and
then signal falls RED to GREEN to pass the car by sending signal from emergency
vehicle to traffic light sensor system and the signal will be RED for other vehicles, so
number of possibility of accident reduces.

1.2 Objectives
If traffic flows were constant over time and known in advance, then calculation of signal
timing plans to optimise a specified objective would be a relatively straightforward matter.
1. Traffic flows vary in several distinct ways that make the control task substantially more
complicated.
2. In particular, flows vary stochastically from moment to moment due to fluctuations in
demand and driver behaviour; flows in urban road networks vary cyclically over time due
1

to upstream signals; flows vary systematically within each day due to peak periods; and
flows change over protracted periods of time due to developing demand for travel.
3. The affects the control of road traffic in different ways, so we will consider their
treatment separately.
4. An engineers main aim is to make the technology which is simple and useful for the
purpose of Light Control.

1.3 Characteristics
High Quality Product (Not hobby grade)
850/ 900/ 1800/ 1900 MHz
1.
2.
3.
4.
5.
6.
7.

Built in RS232 Level Converter (MAX3232)


Configurable baud rate
Built in Network Status LED
Audio interface Connector
Most Status & Controlling Pins are available at Connector
Normal operation temperature: -20 C to +55 C
Input Voltage: 5V-12V DC

1.4 Applications
Following are the applications of Density based Traffic Light Control System, they are:1. Provide the attribute of intelligence to the system.
2. It has the capability of mimicking the human intelligence for controlling the traffic
light flow.
3. It contains the Density which controls the light controller system,
4. A Density based traffic light control system is designed for an isolated four lane
traffic intersection.

1.5 Advantages
Following are the Advantages of Density based Traffic Light Control System, they are:1. Optimum control of fluctuating traffic volumes such as over saturated or unusual load
condition.
2. It improve the vehicular through put.
3. Maximizes the traffic flow.
4. Control the time intervals of the traffic light.

Fig.2.1 Block Diagram of Density Based Traffic Control


4

System
2.2 Description of Block Diagram
The design of the project is basically divided into three section:1. Passive Infrared Sensor (IR)
2. Microcontroller
3. Light Emitting Diode (LED)
4. Power Supply

2.2.1 Passive Infrared Sensor


A Passive Infrared Sensor is an electronic sensor that measure infrared light radiating
from objects in its field of view. They are most often used in PIR based motion detectors.

2.2.1.1 Principle
All objects with a temperature above absolute zero emit heat energy in form of radiation.
Usually this radiation is invisible to the human eye because it radiates at infrared wave
lengths, but it can be detected by electronic device designed for such a purpose.

2.2.1.2 Construction
Materials commonly used in PIR sensors include Gallium Nitride (GaN), Caesium Nitrate
(CsNO3), Polyvinyl Flourides derivatives of Phenylpyridine and Cobalt Phthalocyanine.
The sensor is often manufactured as part of an integrated circuit.

2.2.2 Microcontroller
A Microcontroller is small equipment on a single integrated circuit containing a processor
core, memory and programmable I/O. peripherals, program memory in the form of
ferroelectric RAM, NOR Flash or OTP ROM is also often included on chip, as well as a
typically small amount of RAM, Microcontrollers are designed for ambedded
applications. In contrast to the microprocessors used in personal computers or often
general purpose applications consisting of various discrete chips.
Microcontrollers are used in automatically controlled products and devices, such as
automobile engine control systems such as automobile engine control systems,
5

implantable, medical devices, remote controls, office machines, appliance power tools,
toys and other embedded systems. By reducing the size and cost compared to a designed
that use a separate microprocessors, memory and I/O devices.

2.2.3 Light Emitting Diode (LED)


The main role of LED is to show the colour of light which indicates that when we stop,
ready and go.

2.2.4 Power Supply


In this process we are using a step down transformer, a bridge rectifier, a smoothing
circuit and the RPS.
At the primary of the transformer we are giving the 230V AC supply. The secondary is
connected to the opposite terminals of the Bridge rectifier as the input. From other set of
opposite terminals we are taking the output to the rectifier.
The bridge rectifier converts the AC coming from the secondary of the transformer into
pulsating DC. The output of this rectifier is further given to the smoother circuit which is
capacitor in our project. The smoothing circuit eliminates the ripples from the pulsating
DC and gives the pure DC to the RPS to get a constant output DC voltage. The RPS
regulates the voltage as per our requirement.

2.3 Circuit Diagram


J3

gnd
vcc
3
RS
W
EN
P 0.0
P 0.1
P 0.2
P 0.3
P 0.4
P 0.5
P 0.6
P 0.7
VC C
GND

LC D
VCC

VCC

C4

6
P2

1
C 1+ 3
C 1-

V-

4
C 2+ 5
C 2-

CAP

5
9
4
8
3
7
2
6
1

POT

VCC

V+

14
11
T 1 IN 1 2
13 T1O U T
R 1 IN R 1 O U T
7
10
T 2 IN 9
8 T2O U T
R 2 IN R 2 O U T

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

R6
C5

CAP
C7
U3

CAP
C6

U1

J3

CAP

TXD
R XD

SW 1

C1
C

M A X232

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

CON8

C O N N EC TO R D B9

R4
R

10
11
12
13
14
15
16
17

CON8

18

CAP

1
1

R XD
TXD

RST

P 3 .0 /R XD
P 3 .1 /T XD
P 3 .2 /IN T 0
P 3 .3 /IN T 1
P 3 .4 /T 0
P 3 .5 /T 1
P 3 .6 /W R
P 3 .7 /R D

A L E /P R O G
PSEN

XTA L2

P 2 .7 /A 1 5
P 2 .6 /A 1 4
P 2 .5 /A 1 3
P 2 .4 /A 1 2
P 2 .3 /A 1 1
P 2 .2 /A 1 0
P 2 .1 /A 9
P 2 .0 /A 8

40

J2

39
38
37
36
35
34
33
32

1
2
3
4
5
6
7
8

31

CON8

30
29

J2

28
27
26
25
24
23
22
21

1
2
3
4
5
6
7
8

CON8

C2
19

Y1
C R Y S TA L

20

CAP
D4
D IO D E

C9

D6
D IO D E

U5
1

LM 78 05 /TO

V IN

GND

D2
D IO D E

D1
D IO D E

P 0 .0 /A D 0
P 0 .1 /A D 1
P 0 .2 /A D 2
P 0 .3 /A D 3
P 0 .4 /A D 4
P 0 .5 /A D 5
P 0 .6 /A D 6
P 0 .7 /A D 7
E A /V P P

1
2
3
4
5
6
7
8

C3

U6
t / f ( 4 p in )

VCC

J4

1
2

J7
CON2

P 1 .0
P 1 .1
P 1 .2
P 1 .3
P 1 .4
P 1 .5
P 1 .6
P 1 .7

VOUT

XTA L1
GND

+5V

C8
104

AT89S 52
R5
R

= 1 0 0 0 U F /2 5 V
T it le

C
LED
D5

S iz e
A
D a te :

< T it le >
D ocum ent N um ber
<D oc>
T h u r s d a y , J u ly 1 5 , 2 0 1 0

R ev
<R ev C ode>
Sheet

of

2.3.1 Schematic Description


The main aim of this power supply is to convert the 230V AC into 5V DC in order to give
supply for the TTL. This schematic explanation includes the detailed pin connections of
every device with the microcontroller.
This schematic explanation includes the detailed pin connections of every device with the
microcontroller. Let us see the pin connections of each and every device with the
microcontroller in detail.

2.4 Working
The Density based traffic signal system circuit works or operated by connecting battery or
adaptor of 12volt to the development board. After connecting the battery, switch on the
power supply, burn the program to the ATmega8 microcontroller by keeping the
programming switch SW2 in program mode.
There are four IR sensors which connect to Port C. IR sensors give the digital output and
LEDs are connected to Port B and Port D. LEDs connects in the sequence like traffic
lights i.e. Red, Yellow and Green. Arrange one IR sensor for each road. Now we can see
the normal traffic system based on time basis.
Now, if we place any obstacle infront 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.

3.1 Components
Essential components for assembling GSM based applications including:
1. Power supply or Power Adapter
2. Transformer
3. Capacitor
4. LED
5. Resistor
6. Microcontroller
7. Diode
8. Transistor
9. Relay
10. Oscillator
11. Voltage Regulator

3.1.1 Power Supply


Power supply is the source of electrical power. Normally any electronic circuit uses +5v
DC power for its regular working .User can directly built +5v Dc power supply using 4
diodes, filter capacitors and regulator IC-7805(Integrated Circuit)or can directly purchase
a +5v DC power adopter from the local market.

Fig. 3.1: +5v DC power supply for microcontroller

3.1.2 Transformer
Transformer is a static electrical device which transfers electrical energy from one circuit
to another circuit. Transformer working can be easily understood by its primary and
secondary windings.

Fig. 3.2: Step up Transformer

3.1.3 Capacitor
The capacitor's function is to store electricity, or electrical energy.
The capacitor also functions as a filter, passing alternating current (AC), and blocking
direct current (DC).
This symbol
is used to indicate a capacitor in a circuit diagram. The capacitor is
constructed with two electrode plates facing each other, but separated by an insulator.
When DC voltage is applied to the capacitor, an electric charge is stored on each
electrode. While the capacitor is charging up, current flows. The current will stop flowing
when the capacitor has fully charged.

10

Fig. 3.3: Circuit Diagram of Capacitor


When a circuit tester, such as an analog meter set to measure resistance, is connected to a
10 microfarad (F) electrolytic capacitor, a current will flow, but only for a moment. You
can confirm that the meter's needle moves off of zero, but returns to zero right away.
When you connect the meter's probes to the capacitor in reverse, you will note that
current once again flows for a moment. Once again, when the capacitor has fully charged,
the current stops flowing. So the capacitor can be used as a filter that blocks DC current.
(A "DC cut" filter.)
However, in the case of alternating current, the current will be allowed to pass.
Alternating current is similar to repeatedly switching the test meter's probes back and
forth on the capacitor. Current flows every time the probes are switched.
The value of a capacitor (the capacitance), is designated in units called the Farad ( F ).
The capacitance of a capacitor is generally very small, so units such as the microfarad
(10-6F), nanofarad (10-9F) and picofarad (10-12F) are used. Recently, an new capacitor with
very high capacitance has been developed. The Electric Double Layer capacitor has
capacitance designated in Farad units. These are known as "Super Capacitors."
Sometimes, a three-digit code is used to indicate the value of a capacitor. There are two
ways in which the capacitance can be written. One uses letters and numbers, the other
uses only numbers. In either case, there are only three characters used. [10n] and [103]
denote the same value of capacitance. The method used differs depending on the capacitor
supplier. In the case that the value is displayed with the three-digit code, the 1st and 2nd
digits from the left show the 1st figure and the 2nd figure, and the 3rd digit is a multiplier
which determines how many zeros are to be added to the capacitance. Picofarad (pF)
units are written this way. For example, when the code is [103], it indicates 10 x 10 3, or
10,000pF = 10 nanofarad (nF) = 0.01 microfarad (F).
If the code happened to be, it would be 22 x 10 4 = or 220,000pF = 220nF = 0.22F.
Values under 100pF are displayed with 2 digits only. For example, 47 would be 47pF. The
capacitor has an insulator( the dielectric ) between 2 sheets of electrodes. Different kinds
of capacitors use different materials for the dielectric.

Breakdown Voltage
When using a capacitor, you must pay attention to the maximum voltage which can be
used. This is the "breakdown voltage." The breakdown voltage depends on the kind of
capacitor being used. You must be especially careful with electrolytic capacitors because
the breakdown voltage is comparatively low. The breakdown voltage of electrolytic
capacitors is displayed as Working Voltage. The breakdown voltage is the voltage that
when exceeded will cause the dielectric (insulator) inside the capacitor to break down and
conduct. When this happens, the failure can be catastrophic.
11

3.1.4 Light Emitting Diode (LED)


A light-emitting diode (LED) is a two-lead semiconductor light source. It is apnjunction diode, which emits light when activated. When a suitable voltage is applied to
the leads, electrons are able to recombine with electron holes within the device, releasing
energy in the form of photons. This effect is called electroluminescence, and the color of
the light (corresponding to the energy of the photon) is determined by the energy band
gap of the semiconductor.
An LED is often small in area (less than 1 mm2) and integrated optical components may
be used to shape its radiation pattern.
Appearing as practical electronic components in 1962,[6] the earliest LEDs emitted lowintensity infrared light. Infrared LEDs are still frequently used as transmitting elements in
remote-control circuits, such as those in remote controls for a wide variety of consumer
electronics. The first visible-light LEDs were also of low intensity, and limited to red.
Modern LEDs are available across the visible, ultraviolet, and infrared wavelengths, with
very high brightness.
Early LEDs were often used as indicator lamps for electronic devices, replacing small
incandescent bulbs. They were soon packaged into numeric readouts in the form of sevensegment displays, and were commonly seen in digital clocks.
Recent developments in LEDs permit them to be used in environmental and task lighting.
LEDs have many advantages over incandescent light sources including lower energy
consumption, longer lifetime, improved physical robustness, smaller size, and faster
switching. Light-emitting diodes are now used in applications as diverse as aviation
lighting, automotive headlamps, advertising, general lighting, traffic signals, and camera
flashes. However, LEDs powerful enough for room lighting are still relatively expensive,
and require more precise current and heat management than compact fluorescent
lamp sources of comparable output. LEDs have allowed new text, video displays, and
sensors to be developed, while their high switching rates are also useful in advanced
communications technology.

12

Fig. 3.13: Diagram of LED

3.1.5 Resistor
The resistor's function is to reduce the flow of electric current.
This symbol
is used to indicate a resistor in a circuit diagram, known as a
schematic. Resistance value is designated in units called the "Ohm." A 1000 Ohm resistor
is typically shown as 1K-Ohm ( kilo Ohm ), and 1000 K-Ohms is written as 1M-Ohm
( megohm).
There are two classes of resistors; fixed resistors and the variable resistors. They are also
classified according to the material from which they are made. The typical resistor is
made of either carbon film or metal film. There are other types as well, but these are the
most common. The resistance value of the resistor is not the only thing to consider when
selecting a resistor for use in a circuit. The "tolerance" and the electric power ratings of
the resistor are also important. The tolerance of a resistor denotes how close it is to the
actual rated resistance value. For example, a 5% tolerance would indicate a resistor that
is within 5% of the specified resistance value.
The power rating indicates how much power the resistor can safely tolerate. Just like you
wouldn't use a 6 volt flashlight lamp to replace a burned out light in your house, you
wouldn't use a 1/8 watt resistor when you should be using a 1/2 watt resistor.
The maximum rated power of the resistor is specified in Watts.
Power is calculated using the square of the current ( I 2 ) x the resistance value ( R ) of the
resistor. If the maximum rating of the resistor is exceeded, it will become extremely hot,
and even burn. Resistors in electronic circuits are typicaly rated 1/8W, 1/4W, and 1/2W.
1/8W is almost always used in signal circuit applications.
When powering a light emitting diode, a comparatively large current flows through the
resistor, so you need to consider the power rating of the resistor you choose.

13

Fig. 3.6: Diagram of Resistor

3.1.6 Microcontroller (ATmega8)


3.1.6.1 Features
1. 4.0V to 5.5V Operating Range
2. Fully Static Operation: 0 Hz to 33 MHz
3. Three-level Program Memory Lock
4. 256 x 8-bit Internal RAM
5. 32 Programmable I/O Lines
6. Three 16-bit Timer/Counters
7. Eight Interrupt Sources
8. Full Duplex UART Serial Channel
9. Low-power Idle and Power-down Modes
10. Interrupt Recovery from Power-down Mode
11. Watchdog Timer
12. Dual Data Pointer
13. Power-off Flag

3.1.6.2 Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K
bytes of in-system programmable Flash memory. The device is manufactured using
Atmels high-density nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pin out. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on
a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a
highly-flexible and cost-effective solution to many embedded control applications

14

The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of
RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a sixvector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 is designed with static logic for operation down
to zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM contents but
freezes the oscillator, disabling all other chip functions until the next interrupt or
hardware.

15

Fig. 3.7: Pin Configuration

Pin Description
VCC: Pin 40 provides supply voltage to the chip. The voltage source is + 5V.

16

GND: Pin 20 provides ground.


Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs.
Port 0 can also be configured to be the multiplexed low order address/data bus during
accesses to external program and data memory. In this mode, P0 has internal pull ups.
Port 0 also receives the code bytes during Flash programming and outputs the code bytes
during program verification. External pull ups are required during program verification.
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull ups and can be used as inputs. As inputs, Port 1 pins that
are externally being pulled low will source current (IIL) because of the internal pull ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.

Table 1: PIN Port 1 Description


Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that
are externally being pulled low will source current (IIL) because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program memory
and during accesses to external data memory that uses 16-bit addresses (MOVX @
DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During
17

accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits
the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during Flash
programming and verification.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (IIL) because of the pull-ups.
Port 3 also serves the functions of various special features of the AT89S52, as shown in
the following table. Port 3 also receives some control signals for Flash programming and
verification.

Table 2: PIN Port 3 Description


RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device. This pin drives High for 96 oscillator periods after the Watchdog times
out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In
the default state of bit DISRTO, the RESET HIGH out feature is enabled.

18

ALE/PROG:
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and
may be used for external timing or clocking purposes. Note, however, that one ALE pulse
is skipped during each access to external data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the
bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN:
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
EA/VPP:
External access enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the
12-volt programming enable voltage (VPP) during Flash programming.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:
Output from the inverting oscillator amplifier.

Special Function Registers

19

A map of the on-chip memory area called the Special Function Register (SFR) space is
shown in Table 1. Note that not all of the addresses are occupied, and unoccupied
addresses may not be implemented on the chip. Read accesses to these addresses will in
general return random data, and write accesses will have an indeterminate effect.
User software should not write 1s to these unlisted locations, since they may be used in
future products to invoke new features. In that case, the reset or inactive values of the new
bits will always be 0.
Timer 2 Registers: Control and status bits are contained in registers T2CON (shown in
Table 2) and T2MOD (shown in Table 3) for Timer 2. The register pair (RCAP2H,
RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit
auto-reload mode.
Interrupt Registers: The individual interrupt enable bits are in the IE register. Two
priorities can be set for each of the six interrupt sources in the IP register.

Dual Data Pointer Registers: To facilitate accessing both internal and external data
memory, two banks of 16-bit Data Pointer Registers are provided: DP0 at SFR address
locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and
DPS = 1 selects DP1. The user should always initialize the DPS bit to the appropriate
value before accessing the respective Data Pointer Register.
Power Off Flag: The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON
SFR. POF is set to 1 during power up. It can be set and rest under software control and
is not affected by reset.
Memory Organization
MCS-51 devices have a separate address space for Program and Data Memory. Up to 64K
bytes each of external Program and Data Memory can be addressed.

Program Memory
If the EA pin is connected to GND, all program fetches are directed to external memory.
On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H
20

through 1FFFH are directed to internal memory and fetches to addresses 2000H through
FFFFH are to external memory.
Data Memory
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a
parallel address space to the Special Function Registers. This means that the upper 128
bytes have the same addresses as the SFR space but are physically separate from SFR
space.
When an instruction accesses an internal location above address 7FH, the address mode
used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM
or the SFR space. Instructions which use direct addressing access of the SFR space.
For example, the following direct addressing instruction accesses the SFR at location
0A0H (which is P2).
MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the upper 128 bytes of
data RAM are available as stack space.
Timer 0
The 16-bit register of timer 0 is accessed as low byte and high byte. The low byte register
is called TL0 ( Timer 0 low byte) and the high byte register is referred to as TH0 ( Timer
0 high byte). These registers can be accessed like any other registers , such as
A,B,R0,R1,R2 etc. for example the instruction MOV TL0,#4FH moves the value 4FH
into TL0, the low byte of Timer 0. These registers can also be read like any other register.
For example, MOV R5,TH0 saves TH0 ( high byte of Timer 0) in R5.

Timer 1

21

Timer 1 is also 16 bits and its 16-bit register is split into two bytes, referred to as TL1
(Timer 1 low byte ) and TH1 ( Timer 1 high byte). These registers are accessible in the
same way as the registers of Timer 0.
Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.
The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2).
Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud
rate generator. The modes are selected by bits in T2CON, as shown in Table 3. Timer 2
consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is
incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods,
the count rate is 1/12 of the oscillator frequency.

In the Counter function, the register is incremented in esponse to a 1-to-0 transition at its
corresponding external input pin, T2. In this function, the external input is sampled during
S5P2 of every machine cycle. When the samples show a high in one cycle and a low in
the next cycle, the count is incremented. The new count value appears in the register
during S3P1 of the cycle following the one in which the transition was detected. Since
two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition,
the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is
sampled at least once before it changes, the level should be held for at least one full
machine cycle.
Capture Mode
In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,
Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit
can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same
operation, but a 1- to-0 transition at external input T2EX also causes the current value in
TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the
transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can
generate an interrupt. The capture mode is illustrated in Figure 5.
Auto-reload (Up or Down Counter)
22

Timer 2 can be programmed to count up or down when configured in its 16-bit autoreload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in
the SFR T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that timer 2 will
default to count up. When DCEN is set, Timer 2 can count up or down, depending on the
value of the T2EX pin.

23

Fig. 3.8: Block Diagram of Microcontroller


24

3.1.7 Diode
A diode is a semiconductor device which allows current to flow through it in only one
direction. Although a transistor is also a semiconductor device, it does not operate the
way a diode does. A diode is specifically made to allow current to flow through it in only
one
direction.
Some ways in which the diode can be used are listed here.

1. A diode can be used as a rectifier that converts AC (Alternating Current) to DC


(Direct Current) for a power supply device.

2. Diodes can be used to separate the signal from radio frequencies.


3. Diodes can be used as an on/off switch that controls current.
This symbol
is used to indicate a diode in a circuit diagram. The meaning of the
symbol is (Anode)
(Cathode). Current flows from the anode side to the cathode side.
Although all diodes operate with the same general principle, there are different types
suited to different applications. For example, the following devices are best used for the
applications noted.

3.1.7.1 Types of Diodes


3.1.7.1.1 Voltage regulation diode (Zener Diode)
The circuit symbol is
. It is used to regulate voltage, by taking advantage of the fact
that Zener diodes tend to stabilize at a certain voltage when that voltage is applied in the
opposite direction.

3.1.7.1.2 Light emitting diode


The circuit symbol is
. This type of diode emits light when current flows through it
in the forward direction. (Forward biased.)

3.1.7.1.3 Variable capacitance diode


25

The circuit symbol is


. The current does not flow when applying the voltage of the
opposite direction to the diode. In this condition, the diode has a capacitance like the
capacitor. It is a very small capacitance. The capacitance of the diode changes when
changing voltage. With the change of this capacitance, the frequency of the oscillator can
be changed.

Fig. 3.9: Types of Diode

3.1.8 Transistor
The transistor's finction is to amplify an electric current. Many different kinds of
transistors are used in analog circuits, for different reasons. This is not the case for digital
circuits. In a digital circuit, only two values matter; on or off. The amplification abilitiy of
a transistor is not relevant in a digital circuit. In many cases, a circuit is built with
integrated
circuits(ICs).
Transistors are often
used in digital circuits as
buffers to protect ICs.
For example, when powering
an
electromagnetic
switch (called a 'relay'), or
when controlling a light
emitting diode. (In my case.)
Two different symbols
are used for the transistor.

PNP

NPN type

Fig. 3.10: Transistor


26

type

and

3.1.9 Relay
The relay takes advantage of the fact that when electricity flows through a coil, it
becomes an electromagnet. The electromagnetic coil attracts a steel plate, which is
attached to a switch. So the switch's motion (ON and OFF) is controled by the current
flowing to the coil, or not, respectively.
A very useful feature of a relay is that it can be used to electrically isolate different parts
of a circuit. It will allow a low voltage circuit (e.g. 5VDC) to switch the power in a high
voltage circuit (e.g. 100 VAC or more).
The relay operates mechanically, so it can not operate at high speed. There are many kind
of relays. You can select one according to your needs. The various things to consider
when selecting a relay are its size, voltage and current capacity of the contact points,
drive voltage, impedance, number of contacts, resistance of the contacts, etc. The
resistance voltage of the contacts is the maximum voltage that can be conducted at the
point of contact in the switch. When the maximum is exceeded, the contacts will spark
and melt, sometimes fusing together. The relay will fail. The value is printed on the relay.
On the left in the photograph is a small relay with a coil driving voltage of 12 VDC. It has
two electrically independant points of contact (switches.) Although the resistance and
permissible voltage and current at the point of contact are indistinct, I think that it will
handle several hundred mA.
The relay on the right in the photograph can be used to control a 100 VAC system. Its
driving voltage is 3 VDC, and if it is used to control an AC system, the maximum
resistance voltage is 125 VAC, and the permissible current limit is 1A. If it is used to
control a DC system, the maximum resistance voltage is DC30V, and the permissible
current limit is 2A. It has one contact only.
Both types of relay can be mounted on the PWB; the spacing of the component leads is a
multiple of 0.1 inches. It can also be mounted on the universal PWB.
The physical dimensions of the relay on the left are width 19.5 mm, height 10 mm, and
depth 10 mm. The one that is on the right has the width 20 mm, height 15 mm, and depth
11
mm.

27

Fig. 3.10: Relay

3.10 Oscillator
XTAL1
and
XTAL2 are
the
input
and
output,
respectively, of an
inverting
amplifier that can
be
configured for use
as an onchip oscillator, as shown in Figure 11. Either a quartz crystal or ceramic resonator may be
used. To drive the device from an external clock source, XTAL2 should be left
unconnected while XTAL1 is driven, as shown in Figure 12. There are no requirements
on the duty cycle of the external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high
and low time specifications must be observed. Oscillator connections
Note: C1, C2 = 30 pF 10 pF for Crystals
= 40 pF 10 pF for Ceramic Resonators

Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active.
The mode is invoked by software. The content of the on-chip RAM and all the special
functions registers remain unchanged during this mode. The idle mode can be terminated
by any enabled interrupt or by a hardware reset. Note that when idle mode is terminated
by a hardware reset, the device normally resumes program execution from where it left
off, up to two machine cycles before the internal reset algorithm takes control. On-chip
28

hardware inhibits access to internal RAM in this event, but access to the port pins is not
inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode
is terminated by a reset, the instruction following the one that invokes idle mode should
not write to a port pin or to external memory.
Power-down Mode
In the Power-down mode, the oscillator is stopped, and the instruction that invokes
Power-down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the Power-down mode is terminated. Exit from Powerdown mode can be initiated either by a hardware reset or by an enabled external interrupt.
Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be
activated before VCC is restored to its normal operating level and must be held active
long enough to allow the oscillator to restart and stabilize. Status of External Pins during
Idle and Power-down Modes

Table 4: Oscillator Power Down Mode

3.1.11 Voltage Regulator


7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear
voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not
give the fixed voltage output. The voltage regulator IC maintains the output voltage at a
constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide.
7805 provides +5V regulated power supply. Capacitors of suitable values can be
connected at input and output pins depending upon the respective voltage levels.

29

Fig. 3.11: Voltage Regulator 7805

Fig. 3.12: Pin diagram of Voltage


regulator 7805

30

4.1 Concept of Embedded C


4.1.1 Introduction
An embedded system is some combination of computer hardware and software, either
fixed in capability or programmable, that is specifically designed for a particular function.
Industrial machines, automobiles, medical equipment, cameras, household appliances,
airplanes, vending machines and toys (as well as the more obvious cellular phone and
PDA) are among the myriad possible hosts of an embedded system. Embedded systems
that are programmable are provided with programming interfaces, and embedded systems
programming is a specialized occupation.
Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, some lowend consumer
products use very inexpensive microprocessors and limited storage, with the application
and operating system both part of a single program. The program is written permanently
into the system's memory in this case, rather than being loaded into RAM (random access
memory) like programs on a personal computer.
Most C programmers are spoiled because they program in environments where not only is
there a standard library implementation, but there are frequently a number of other
libraries available for use. The cold fact is, that in embedded systems, there rarely are
many of the libraries that programmers have grown used to, but occasionally an
embedded system might not have a complete standard library, if there is a standard library
at all. Few embedded systems have capability for dynamic linking, so if standard library
functions are to be available at all, they often need to be directly linked into the
executable. Oftentimes, because of space concerns, it is not possible to link in an entire
library file, and programmers are often forced to "brew their own" standard c library
implementations if they want to use them at all. While some libraries are bulky and not
well suited for use on microcontrollers, many development systems still include the
standard libraries which are the most common for C programmers.
C remains a very popular language for microcontroller developers due to the code
efficiency and reduced overhead and development time. C offers lowlevel control and is
considered more readable than assembly. Many free C compilers are available for a wide
variety of development platforms. The compilers are part of an IDEs with ICD support,
breakpoints, single-stepping and an assembly window. The performance of C compilers
has improved considerably in recent years, and they are claimed to be more or less as
good as assembly, depending on who you ask. Most tools now offer options for
customizing the compiler optimization. Additionally, using C increases portability, since
C code can be compiled for different types of processors.

31

4.1.2 Concept of Embedded Systems in C


An embedded system is a system that connects preprogrammed software on a controller
embedded in the computer hardware. The software is installed on the controller, the
brains of the electronic device. Each embedded system is used for one specific function.
A complex device like a PDA or smart phone may have embedded devices that can
control several functions. However, embedded systems are not as complex or
programmable as a personal computer. C is one of the most commonly used programming
languages in embedded devices. Embedded systems are used to control electronic devices
such as DVD players, cell phones, watches and medical devices. Video cards and network
switches are embedded systems used in computer peripherals. The cruise control and antilock brakes in a car are also embedded systems. Embedded systems are cheaper than
complex processors due to their simplicity and frequent mass production. Software
written in a language like C is used to control the mechanical devices within the
embedded system.

Reasons C is Common in Embedded Systems


C is one of the most commonly used software languages used on embedded device
controllers. One reason is because it is one of the few software languages that operates on
both 8 bit controllers and 64 bit PCs, meaning that many computer programmers can
write C software for both personal computers and embedded devices. The C language can
also use very simple commands to control the device, freeing up the limited memory of
the device to hold many commands or parameters. C can be written for both
microcontrollers and digital signal processors.

C Languages Used in Embedded Systems


C and C!! are used frequently in creation of embedded systems. Embedded systems are
rarely programmed using the C++ because embedded systems rarely have the memory
space for the complex programming used in C++. C# is occasionally used on embedded
Linux systems.

How C Programs Are Created and Installed on Embedded Systems


Code is written in C on a programmer's PC. Code is run through a compiler on the
programmer's PC to create a software program. The embedded system software may be
run through a simulator on the programmer's computer. The software program is copied
onto the controller using a "programmer." The controller is then tested on a "test bed" to
ensure that it works properly.

32

Common Embedded Systems that Use C


Bluetooth devices are programmed in C. PIC microcontrollers such as those used in web
cameras are frequently programmed in C. PIC microcontrollers programmed in C have
also been used in LED (light emitting diodes) devices and LCD (liquid crystal display)
monitors. USB devices are embedded devices frequently coded in C.

Standards for Embedded System Programming in C


The American National Standards Institute (ANSI) has written standards for the C
programming language. The International Standards Organization wrote standard
ISO/IEC 9899 for the C programming language. The Motor Industry Software Reliability
Association has created a proprietary set of standards for programming in C for
embedded devices in automobiles.

4.1.3 How C is used Differently for Embedded Programming


If you are new to embedded C programming, you will notice that there are only subtle
differences between a regular C program and an embedded C program. The following is a
list of the most important differences between C programming for embedded systems and
C programming for PCs.

4.2 AVR Studio 4

33

Trying to connect to AVR Studio 4


Press RESET button on AVR board and click connect as shown below.

34

Connection established with AVR studio 4

35

36

Programming the AVR

AVR Studio 4 Software version

37

Close the programmer screen (not the IDE) and click RESET button on the board to start
executing your program (few seconds delay).

CONCLUSION
38

Traffic control system was developed where the traffic load is continuously measured by
sensors connected to a microcontroller based system which also performs all intersection.
Control function, intersection controller of an area are interconnected with a
communication network through which traffic load and synchronization information is
exchanged.
As a result, the duration and relative phases of each traffic light cycle change
dynamically. For this basic function of the system only the intersection controller are
required.

39

FUTURE SCOPE
This project can be enhanced in such away as to control automatically the signals
depending on the traffic density on the roads using sensors like IR detector receiver
module extended with automatic turn off when no vehicles are running on any side of the
road which keeps in power consumption saving number of passing vehicle in the fixed
time slot on the road decide the density range of traffic and on the basis of vehicles count
microcontroller decide the traffic light delays for next recording interval. Traffic light
control can be done for whole city by sitting on a single place,
In future this system can be used to inform people about different places traffic condition.
This can be done through RADIO.

40

REFERENCES
1. Ali, AT, Crosta, DA, Allsop, RE, Heydecker, BG, Robertson, DI and Vincencio-Silva,
M-A (1999) Improved traffic signal control using image analysis. Paper presented to
the 31st UTSG Annual Conference, University of York, January 1999 (unpublished).
2. Allsop, RE (1971) Delay minimizing settings for fixed-time traffic signals at a single
road junction. Journal of the Institute of Mathematics and its Applications, 8(2), 16485.
3. Allsop, RE (1976) SIGCAP: a computer program for assessing the traffic capacity of
signalcontrolled road junctions. Traffic Engineering and Control, 17(8/9), 338-41.
4. Bell, MGH (1992) Future directions in traffic signal control. Transportation
Research, 26A(4), 303-13.
5. Bell, MC (1983) A survey of the methods used to define and change signal plans in
the UK. Research Report 50. Transport Operations Research Group, University of
Newcastle upon Tyne.
6. Bell, MC and Bretherton, RD (1986) Ageing of fixed-time traffic signal plans.
Proceedings of the 2nd IEE Conference on Road Traffic Control. London: IEE.
7. Bell, MC, Gault, HE and Taylor, IG (1983) Plan change algorithms for area traffic
control systems. Research Report 51. Transport Operations Research Group,
University of Newcastle upon Tyne.
8. Bretherton, RD (1979) Five methods of changing fixed-time traffic signal plans.
Transport and Road Research Laboratory Report: LR 879. Crowthorne: TRL.
9. Brown, RG and Hwang PYC (1992) Introduction to random signals and applied
Kalman filtering. Chichester: Wiley.
10. DETR (1997) Junction principles of control by traffic signals. Design Manual for
Roads and Bridges, 8.1, TA 16/81. London: TSO.
11. Gallivan, S and Heydecker, BG (1988) Optimising the control performance of traffic
signals at a single junction. Transportation Research, 22B(5), 357-70.
12. Gartner NH (1983) OPAC: a demand-responsive strategy for traffic signal control.
Transportation Research Record, 906, 75-84.
13. Gartner NH, Kaltenbach MH and Miyamoto MM (1983) Demand-responsive
decentralized urban traffic control, part II: network extensions. Report DOT/OST/P34/85/009.
41

14. Gazis, DC and Potts, RB (1963) The over-saturated intersection. Proceedings of the
Second International Symposium on the Theory of Road Traffic Flow (ed J Almond),
Paris: OECD, 221-37.
15. Grafton, RB and Newell, GF (1965) Optimal policies for the control of an
undersaturated intersection. In: Vehicular Traffic Science (eds LC Edie, R Herman
and R Rothery). New York: Elsevier, 239-57.
16. Hertz, J, Krogh, A and Palmer, R (1991) Introduction to the theory of neural
computation. London: Addison Wesley.
17. Heydecker, BG and Bressaud, X (1992) Filtering detector data for real-time traffic
control systems. Note from the Transport Studies Group, University College London.
18. Heydecker, BG and Dudgeon, IW (1987) Calculation of signal settings to minimise
delay at a junction. In: Transportation and Traffic Theory (eds NH Gartner and NHM
Wilson). New York: Elsevier, 159-78.
19. Holland JH (1975) Adaptation in Natural and Artificial Systems, University of
Michigan Press.
20. Holroyd, J (1972) Comparison between a dynamic signal plan generation system of
area traffic control and a fixed-time system. Transport and Road Research Laboratory
Report: LR 487. Crowthorne: TRL.
21. Hunt, PB, Robertson, DI, Bretherton, RD and Winton, RI (1981) SCOOT a traffic
responsive method of coordinating signals. Transport and Road Research Laboratory
Report LR 1014. Crowthorne: TRL.
22. Improta, G and Cantarella, GE (1984) Control system design for an individual
signalized junction. Transportation Research, 18B(2), 147-67.
23. Kamien, MI and Schwartz, NL (1991) Dynamic optimisation: the calculus of
variations and optimal control in economics and management. London: NorthHolland.
24. Lighthill, MJ (1958) Introduction to Fourier analysis and generalised functions.
Cambridge University Press.
25. Lighthill, MJ and Whitham, GB (1955) On kinematic waves II. A theory of traffic
flow on long crowded roads. Proceedings of the Royal Society, 229A, 317-45.
26. Lo, H (1999) A Novel Traffic Signal Control Formulation. Transportation Research,
33A(6), 433-448.
27. Lo, H, Chang, E and Chan, YC (2000) Dynamic Intersection Signal Control
Optimization (DISCO): Numerical Results for Argyle Street. Hong Kong Institution
of Engineers Transactions, 6(3), 1-7.
42

28. Lo, HK and Chow, HF (2003) Adaptive traffic control: control strategy, prediction
resolution, and accuracy. Journal of Advanced Transportation, 36(3), 323-47.
29. Lowrie, PR (1982) The Sydney co-ordinated adaptive traffic system principles,
methodology, algorithms. Proceedings of the IEE International Conference on Road
Traffic Signalling, Conference Publication 207. London: IEE, 67-70.
30. Lowrie, PR (1991) SCATS: Sydney co-ordinated adaptive traffic system a traffic
responsive method of controlling urban traffic. Sydney: Roads and Traffic Authority.
31. Miller, AJ (1963a) Settings for fixed-cycle traffic signals. Operational Research
Quarterly, 14(4), 373-86.
32. Miller, AJ (1963b) A computer control system for traffic networks. Proceedings of the
Second International Symposium on the Theory of Road Traffic Flow (ed J Almond),
Paris: OECD, 200-20.
33. Quinn, D (1992) A review of queue management strategies. Traffic Engineering and
Control, 33(11), 600-5.
34. Ribeiro, PCM (1994) Handling traffic fluctuations with fixed-time plans calculated by
TRANSYT. Traffic Engineering and Control, 35(10), 362-6.
35. Robertson, DI (1969) TRANSYT: a traffic network study tool. Transport and Road
Research Laboratory Report: LR 253. Crowthorne: TRL..
36. Robertson, DI and Bretherton, RD (1974) Optimum control of an intersection for any
known sequence of vehicular arrivals. Proceedings of the 2nd IFAC-IFIP-IFORS
Symposium on Traffic Control and Transportation Systems.
37. Robertson, DI, Lucas, CF and Baker, RT (1980) Coordinating traffic signals to reduce
fuel consumption. Transport and Road Research Laboratory Report: LR 934.
Crowthorne: TRL. Sayers, T, Anderson, J and Clement, S (1996) The multi-objective
optimisation of a traffic control system. In: Transportation and Traffic Theory (ed A
Ceder). Haifa: The Technion, 153-76.
38. ShaAban, J, Tomlinson, A, Heydecker, BG and Bull, L (2002) Addressing policy
objectives of traffic control using evolutionary algorithms. Proceedings of the
European Transport Conference, Seminar on Making Better Use of the Network.
London: PTRC.
39. Van Zuylen, H (1976) Acyclic traffic controllers. Note from the Transport Studies
Group, University College London.
40. Vincent, RA and Peirce, JR (1988) MOVA: traffic responsive, self-optimising signal
control for isolated intersections. Transport and Road Research Laboratory Report
RR 170. Crowthorne: TRL.
43

41. Webster, FV (1958) Traffic signal settings. Road Research Technical Paper 39.
London: HMSO.
42. Wood, K (1993) Urban traffic control, systems review. Transport and Road Resaerch
Laboratory Report PR 41. Crowthorne: TRL.

#include<AT89X51.h>
#include<string.h>
Voidmain()
44

{
Int i,a;
TRI SA=0*01;
TRI SB=0*00;
TRI SC=0*00;
TRI SD=0*00;
While(1)
{
a=0*50;
PORT B=0*1C;
PORT C=0*11;
For{i=0;I<=14;i++ }
{
PORT D=a;
a=a--;
Delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
45

}
}
PORT B=0*14;
PORT C=0*11;
For{i=14;i<=49;i++}
{
PORT D=a;
a=a--;
delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
}
}
PORT D=0*00;
PORT B=0*12;
a=0*05;
for{i=0;i<=4;i++}
{
46

PORT D=a;
a=a--;
delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
}
}
a=0*50;
PORT B=0*C1;
PORT C=0*11;
For{i=0;i<=14;i++}
{
PORT D=a;
a=a--;
delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
47

}
}
PORT B=0*41;
PORT C=0*11;
For{i=14;i<=49;i++}
{
PORT D=a;
a=a--;
delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
}
}
PORT D=0*00;
PORT B=0*21;
A=0*05;
For{i=0;I<=4;i++}
{
48

PORT D=a;
a=a--;
delay_ms(100);
If{a==0*2F||a==0*1F||a==0*0F||a==0*3F||a==0*4F}
{
a=a-6;
}
}

49

You might also like