0% found this document useful (0 votes)
3 views

PBL Introduction to Embedded System

Uploaded by

Hafiz Muhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PBL Introduction to Embedded System

Uploaded by

Hafiz Muhammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

National University of Technology,

Islamabad
NUTECH
Problem Based Learning
Course: Introduction to Embedded
System
Department: Electrical Engineering
Batch: Fall 2022

Nutech ID: F22603006


Submitted By: Salman Sajid

Submitted To: Lec. Syed Shahzad Date: Dec


26, 2024

Problem Statement:
Now a days vehicle parking is a major concern in urban areas due to increasing
number of vehicles. When a vehicle trying to locate the empty slot, it slows down
the overall traffic on the road and results in the congestion near the parking area.
This can also be the cause of accident and there is a need of smart parking system.
The smart parking system is not about creating more parking space but making it
easier for people to locate the empty parking spaces so that the time spent on the
road may significantly reduce. In the smart parking system, there will be a display
unit on the entrance of the parking arena and shows the total number of available
parking slots. Whenever a vehicle enters the parking arena the total count will be
decremented by one and in case a vehicle goes out from parking arena the total
count will be incremented by one. If the parking area is full and there is no empty
slot for vehicle the count on the display will be zero.

You are required to make the prototype of smart parking system using PIC18F with
maximum parking limit of 50. There will be two different sensors to detect the
incoming and outgoing vehicle. Both sensors are digital sensors and send HIGH
signal when vehicle is detected otherwise send LOW signal. To display the
available slots, use the seven-segment display. Fig.1 shows the seven-segment
display.

Fig.1 Seven Segment Display


The 7-segment display consists of seven LEDs arranged in a rectangular fashion.
Each of the seven LEDs is called a segment because when illuminated the segment
forms part of a numerical digit to be displayed. There are two types of seven
segment displays: 1) Common Anode 2) Common Cathode. In the common cathode
display, all the cathode connections of the

LED’s are joined together to ground and individual segments are illuminated by
HIGH signal to the individual Anode terminals. On the other hand, in common
anode display, all the anode connections are joined together to HIGH signal and
individual segments are illuminated by sending LOW signal to the individual
Cathode terminals.

Develop a program C18 for PIC18F which meets the above specifications along
with the required circuitry/schematic to accomplish the task. Consider the seven
segment as common cathode.

Code Implementation:
#include <p18f452.h>

#pragma config OSC = HS

#pragma config WDT = OFF

#define in PORTBbits.RB0

#define out PORTBbits.RB1

void main()

int maxslots = 50;

unsigned char segment[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07,
0x7F, 0x6F};

TRISBbits.TRISB0 = 1;

TRISBbits.TRISB1 = 1;

TRISC = 0;

TRISD = 0;
PORTC = 0x6D;

PORTD = 0x3F;

while (1)

if (in == 1 && maxslots > 0)

maxslots--;

PORTD = segment[maxslots % 10];

PORTC = segment[maxslots / 10];

while (in == 1);

else if (out == 1 && maxslots < 50)

maxslots++;

PORTD = segment[maxslots % 10];

PORTC = segment[maxslots / 10];

while (out == 1);

Output:

You might also like