Av 314 Lab 6 Group 3
Av 314 Lab 6 Group 3
LAB REPORT 06
GROUP 03
UP COUNTER AND DOWN COUNTER WITH ITS IMPLEMENTATION ON TRAFFIC
LIGHTS
SUBMITTED BY:
A/C SHAYAN BAIG 21097004
SUBMITTED TO:
LE FAZAL UR REHMAN
Abstract:
This lab report's objective is to use a microcontroller to simulate, design, and implement a traffic
light control system. This entails putting a counter on the hardware and integrating a 7-segment
display using the supplied code.
Initialize count to 0
DO FOREVER
Seg_Data_0 = bcd_0
Activate Segment_0
Seg_Data_1 = bcd_1
Activate Segment_1
Seg_Data_2 = bcd_2
Activate Segment_2
Seg_Data_3 = bcd_3
Activate Segment_3
Increment count
count = 0
ENDIF
Delay 1 second
ENDDO
END
CODE:
const char seg[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; // 7-segment
void main(void) {
char *bcd_data;
int delay;
while (1) {
char i = 0;
SCREENSHOTS:
Task 2: Down Counter with 7-segment Display
PSEDUO CODE:
START
Initialize count to 0
DO FOREVER
Seg_Data_0 = bcd_0
Activate Segment_0
Seg_Data_1 = bcd_1
Activate Segment_1
Seg_Data_2 = bcd_2
Activate Segment_2
Seg_Data_3 = bcd_3
Activate Segment_3
Increment count
count = 0
ENDIF
Delay 1 second
ENDDO
END
CODE:
const char seg[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; // 7-segment
display codes
void main(void) {
char *bcd_data;
int delay;
while (1) {
Delay_ms(1000);
char i = 0;
SCREENSHOTS:
Switch on num:
CODE:
// Define global variables
switch (num) {
void Yellow() {
PORTC.F1 = 0;
PORTC.F2 = 1;
PORTC.F3 = 0;
// Display tens digit
PORTD.F1 = 1;
delay_ms(10);
10
PORTD.F1 = 0;
PORTD.F2 = 1;
delay_ms(10);
PORTD.F2 = 0;
void Green() {
PORTC.F1 = 0;
PORTC.F2 = 0;
PORTC.F3 = 1;
PORTD.F1 = 1;
delay_ms(10);
PORTD.F1 = 0;
PORTD.F2 = 1;
delay_ms(10);
PORTD.F2 = 0;
void Red() {
11
PORTC.F1 = 1;
PORTC.F2 = 0;
PORTC.F3 = 0;
PORTD.F1 = 1;
delay_ms(10);
PORTD.F1 = 0;
PORTD.F2 = 1;
delay_ms(10);
PORTD.F2 = 0;
// Main function
void main() {
while (1) {
SCREENSHOTS: