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

Flow Chart of Micro C Code Assignment 1

The document contains flow charts and code for three Micro C assignments that control LEDs on a microcontroller board. Assignment 1 turns all LEDs on when a button is pressed and off when not pressed. Assignment 2 turns on one LED for 500ms then the next LED and so on in a loop. Assignment 3 is similar but lights the LEDs in ascending then descending order in a continuous loop.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
317 views

Flow Chart of Micro C Code Assignment 1

The document contains flow charts and code for three Micro C assignments that control LEDs on a microcontroller board. Assignment 1 turns all LEDs on when a button is pressed and off when not pressed. Assignment 2 turns on one LED for 500ms then the next LED and so on in a loop. Assignment 3 is similar but lights the LEDs in ascending then descending order in a continuous loop.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

1) Flow chart of Micro C code ASSIGNMENT 1

BEGIN

TRISB=0b00000000;
PORTB=0b00000000;
ADCON=0b00000110;
TRISA=0b11111111

LED 0 is ON
YES
BUTTON
=0

LED 1 is ON
LED 2 is ON
LED 3 is ON

NO
LED 0 is OFF
LED 1 is OFF
LED 2 is OFF
LED 3 is OFF
LED 4 is OFF
LED 5 is OFF
LED 6 is OFF
LED 7 is OFF

THE CODE OF ASSIGNMENT 1

LED 4 is ON
LED 5 is ON
LED 6 is ON
LED 7 is ON

Void main (void)


{
TRISB = 0b00000000;
PORTB = 0b00000000;
TRISB = 0b11111111;
ADCON1 = 0b00000110;

While (1) {
If (PORTA.F4 == 0)
{
PORTB.F0 = 1;
PORTB.F1 = 1;
PORTB.F2 = 1;
PORTB.F3 = 1;
PORTB.F4 = 1;
PORTB.F5 = 1;
PORTB.F6 = 1;
PORTB.F7 = 1;
}
else
{
PORTB.F0 = 0;
PORTB.F1 = 0;
PORTB.F2 = 0;
PORTB.F3 = 0;
PORTB.F4 = 0;

PORTB.F5 = 0;
PORTB.F6 = 0;
PORTB.F7 = 0;
}
}
}

FLOWCHART OF ASSIGNMENT 2

BEGI
N

TRISB = 0b00000000;
PORTB = 0;

LED is ON

DELAY = 500ms

LED is ON
DELAY = 500ms

THE CODE OF ASSIGNMENT 3


void main(void)
{
TRISB = 0b00000000;
PORTB = 0;
while(1)
{
PORTB = 0b00000001;
Delay_ms (1000);
PORTB = 0b00000010;
Delay_ms (1000 );
PORTB = 0b00000100;
Delay_ms (1000 );
PORTB = 0b00001000;
Delay_ms (1000 );
PORTB = 0b00010000;

Delay_ms (1000 );
PORTB = 0b00100000;
Delay_ms (1000 );
PORTB = 0b01000000;
Delay_ms (1000 );
PORTB = 0b10000000;
Delay_ms (1000 );
PORTB = 0b10000000;
Delay_ms (1000 );
PORTB = 0b01000000;
Delay_ms (1000 );
PORTB = 0b00100000;
Delay_ms (1000 );
PORTB = 0b00010000;
Delay_ms (1000 );
PORTB = 0b00001000;
Delay_ms (1000 );
PORTB = 0b00000100;
Delay_ms (1000 );
PORTB = 0b00000010;
Delay_ms (1000 );
PORTB = 0b00000001;
Delay_ms (1000);
}
}
FLOW CHART OF ASSIGNMENT 3

BEGI
N
TRISB = 0b00000000;
PORTB = 0;
C
LED 0 is ON

DELAY = 500ms

LED 1 is ON

DELAY = 500ms

LED 2 is ON

DELAY = 500ms
LED 3 is ON

DELAY = 500ms

LED 4 is ON

LED=5 500ms
is ON
DELAY

DELAY = 500ms

LED 6 is ON
LED
LED
LED7
75
4
6
is
is
ON
ON
ON
DELAY
DELAY
=
=is
500ms
500ms

B
B

LED 3 is ON

DELAY = 500ms

LED 2 is ON
DELAY = 500ms

You might also like