Professional Documents
Culture Documents
________________________________________________________________________________________________________
_______________________________________________________________________________________________________
Embedded Systems
COE349
College: Engineering and Information Technology
Department: Electrical and Computer Engineering
ROAD TECH.
ABSTRACT
The project name gives up the idea of the project. In this project we
implement road technology such as radar sensors, pedestrian
crossing as well as traffic signal using microcontrollers.
Done by:
❖Khadija Muhammad 201811672
ADVANTAGES DISADVANTAGES
• Lower cost because many • Less flexibility because all
elements of the processor are components are integrated into
contained within the one chip the one chip.
resulting in lower chip cost and • Limited performance because the
board cost. size of memory is limited by what
• Lower power consumption. can be accommodated on the
• Integrating all components onto chip.
one chip enables processor to be • MCUs tend to be application
optimized for a given application. specific so the choice may be
limited.
PIC16F887 Pinout
Getting a hold of Pinout and Pin descriptions is mandatory to check the working of each pin on this tiny chip. If
you are a newbie or an expert, you need to know the function associated with each pin for a better
understanding of the chip.
WORKING
It is a two-way road where either the car can go straight or make a U-turn. There is radar which detects the
speed of the car and displays the speed. It also had pedestrian crossing on both the sides of the roads.
TRAFFIC SIGNAL
• By default, Signal 1 is Green, and Signal 2 is Red. The timer counts down from 9 to 0.
• Both the Signals turn Yellow, and the timer starts counting down from 3 to 0.
• Then Signal 2 becomes Green, and Signal 1 becomes Red. The timer counts down from 9 to 0.
• And this repeats continuously.
PEDESTRIAN
• By default, both the Pedestrian crossing are RED (STOP).
• When Pedestrian button is pushed while Signal 1 is Green, and Signal 2 is Red.
o Both the Signals will turn into Yellow countdown of 3 seconds will start. While the pedestrian
lights are still RED.
o After the countdown both the signals will become Red, and the pedestrian light will turn into
GREEN (WALK) for 9 seconds.
o After the countdown of pedestrian is over. The Pedestrian lights will turn to RED (STOP).
o Both the Signals will be Yellow for 3 seconds.
o Now Signal 1 is Red, and Signal 2 is Green.
• When Pedestrian button is pushed while Signal 1 is Red, and Signal 2 is Green.
o Both the Signals will turn into Yellow countdown of 3 seconds will start. While the pedestrian
lights are still RED.
o After the countdown both the signals will become Red, and the pedestrian light will turn into
GREEN (WALK) for 9 seconds.
o After the countdown of pedestrian is over. The Pedestrian lights will turn to RED (STOP).
o Both the Signals will be Yellow for 3 seconds.
o Now Signal 1 is Green, and Signal 2 is Red.
RADAR
• When the car is under speed of 100 km/hr. The radar sensor will sense it and display the speed of the car
and Smiley emoticon on the radar display.
• When the car is over the speed limit of 100 km/hr. The radar sensor will sense it and display the speed of
the car with a sad emoticon on the radar display. And displays a message “Please Slow Down”.
• The pull-up mode is used for MCLEAR which will work in active low mode.
• When the button is pushed. The Microcontroller is cleared.
The pull-down is used for Pedestrian which will work in Active high mode for interrupts. •
When the button is pushed. Appropriate action is taken. •
Traffic Signal:
• Signaling devices that control the flow of traffic.
• Red: stop (disallow traffic from going on), yellow: get
ready to stop, green: go (allow traffic to go).
ADVANTAGES DISADVANTAGES
• Small. • Consume power.
• Intensity of light depend • Cost is high.
on current flow.
• High efficiency.
4511 Decoders
• BCD decoder.
• Used to convert a BCD to an equivalent decimal number.
• Takes a binary number as input then display it on 7-segment display using
its outputs.
• Reduce the controller pins by using only 4 lines to drive the 7-segment.
Potentiometer:
• Variable resistor.
• Resistance manually changed to control the flow of
current.
• Work: when varying the position of the sliding contact.
External Interrupt:
• Special events that need immediate attention, it stops the microcontroller from running to do task.
• Interrupt triggered by changing of pin RB0 of PORTB.
• Change happens in two cases:
o Negative edge: high to low transition.
o Positive edge: low to high transition.
• Registers used:
• INTCON:
ADC in PIC16F887
• Uses 10-bit ADC module.
• Max count obtained = 210 = 1024.
• Consists of 14 pins/channels from AN0 to AN13.
• Reference voltage is software selectable, so, it can be generated internally or provided externally.
• The interrupt can be enabled or disabled, it happens when 1 full conversion is done.
o We enable the inbuilt ADC that is present in the microcontroller by setting the least significant bit of
ADCON0 to ‘1’.
o To select the V+ref and V-ref we use ADCON1 register. Where the reference voltages are by
default set to Vss and Vdd.
o ADFM = 0 : left justified result, ADFM=1 : right justified result.
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Speed: ");
Lcd_Out(1,8,S_ch); //DISPLAY SPEED
CustomChar2(1,13); //DISPLAY SMILEY
return;
}
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
int L,flag=0;
void pedestrian()
{
for(i= 3;i>=0;i--) //Yellow light for both signals
{
PORTD=i;
led_Green1=0;
led_Green2=0;
led_Red1=0; led_Red2=0;
led_Yellow2=1;led_Yellow1=1;
Delay_ms(600);
radar();
}
PORTA.F3=0;
for(L=9; L>=0;L--) //both signals are red for pedestrian to cross
{
PORTD=L;
led_Green1=0;
led_Green2=0;
led_Yellow1=0;
led_Yellow2=0;
led_Red1=1; led_Red2=1;
Delay_ms(600);
radar();
PORTA.F2=1;
}
flag=0; // clear flag
PORTA.F3=1; //switch on red light for pedestrian
PORTA.F2=0; //swith off green light
}
//---------------------------------------------------------------------------------------
void interrupt ()
{
if(INTCON.INTF==1)
flag=1; //set flag
INTCON.INTF=0;
}
//---------------------------------------------------------------------------------------
void main()
{
ANSEL=0X02; //CHANNEL 1
ANSELH=0;
ADCON0=0x01; //ENABLE ADC
TRISA.F1=1; //SENSOR INPUT AT CHANNEL 1
ADCON1.F4=0;
ADCON0.F5=0;
TRISA.F2=TRISA.F3=0;
INTCON.GIE=1; //global interrupt is enabled
INTCON.INTE=1;
INTCON.INTF=0; //interrupt flag is set to 0
do{
PORTA.F3=1; //Red light for pedestrian is switched on
//indicating to stop walking
radar(); // call radar function
PORTC=0;
for(i=9;i>=0;i--) //Counter for the signals
{
PORTD=i; //display count to the 7 seg
led_Green1=1; led_Red2=1;
Delay_ms(800);
radar();
if(flag==1) // we check if pedestrian wants to cross or not
{
pedestrian(); // we call pedestrian function
break;
}
//PHASE2
PORTC=0;
for(i= 3;i>=0;i--) //Yellow light for both signals //Counter for the signals
{
PORTD=i;
led_Yellow2=1;led_Yellow1=1;
Delay_ms(600);
radar();
if(flag==1)
{
pedestrian();
i=3;
}
}
PORTC=0;
//PHASE4
PORTC=0;
for(i=3;i>=0;i--) //Yellow light for both signals //Counter for the signals
{
PORTD=i;
led_Yellow2=1;led_Yellow1=1;
Delay_ms(600);
radar();
if(flag==1)
{
} // end of program
//---------------------------------------------------------------------------------------
By default, signal 1 is GREEN and signal 2 is RED. The speed is less than 100 km/hr. Therefore,
only speed is displayed and a smiley emoticon. Pedestrian is not enabled. The countdown
starts at 9.
References
• https://www.elprocus.com/lcd-16x2-pin-configuration-and-its-working/
• https://www.electronicsforu.com/technology-trends/learn-electronics/16x2-lcd-pinout-diagram
• https://circuitdigest.com/microcontroller-projects/custom-characters-on-lcd-using-pic16f877a
• https://circuitglobe.com/light-emitting-diode-led.html
• https://www.electronics-tutorials.ws/diode/diode_8.html
• https://www.electrical4u.com/potentiometer/
• https://www.electrical4u.com/what-is-resistor/
• https://www.electronics-tutorials.ws/blog/7-segment-display-tutorial.html
• http://lednique.com/display-technology/7-segment-display-basics/
• https://www.elprocus.com/bcd-to-seven-segment-display-decoder-theory/
• https://www.build-electronic-circuits.com/4000-series-integrated-circuits/ic-4511/
• https://openlabpro.com/guide/push-button-interfacing-with-pic16f877a/
• https://openlabpro.com/guide/push-button-interfacing-with-pic-microcontroller/
• https://embetronicx.com/tutorials/microcontrollers/pic16f877a/pic16f877a-interrupt-
tutorial/#PIC16F877A_Interrupt_Tutorial
• https://hangcafe.wordpress.com/2017/08/30/using-pic16f887-external-interrupt-in-mikroc/
• https://techetrx.com/pic-microcontroller/adc-in-pic16f887-microcontroller/
• https://circuitdigest.com/microcontroller-projects/pic-microcontroller-pic16f877a-adc-
tutorial
• https://internetofthingsagenda.techtarget.com/definition/microcontroller
•
• https://www.electronics-notes.com/articles/digital-embedded-processing/embedded-
systems/what-is-embedded-microcontroller-mcu.php
•
• https://components101.com/microcontrollers/pic16f887-microcontroller
•
• https://www.theengineeringprojects.com/2018/08/introduction-to-pic16f887.html