0% found this document useful (0 votes)
67 views5 pages

Create and Simulate A Code To Turn On or Off The Six Leds of The Figure 1, One Each Time With The Sequence D1, D2, D3, D4, D5, D6

The document describes a code written to sequentially turn on and off 6 LEDs (D1 to D6) using an PIC18F4550 microcontroller. The code uses pins B0, B1 and B2 to control the LEDs, turning one on for 1 second while turning the others off, in the sequence of D1, D2, D3, D4, D5 and D6. The code and its simulation, showing each LED turning on individually while the others remain off, are included.

Uploaded by

P8YCG9PW64
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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views5 pages

Create and Simulate A Code To Turn On or Off The Six Leds of The Figure 1, One Each Time With The Sequence D1, D2, D3, D4, D5, D6

The document describes a code written to sequentially turn on and off 6 LEDs (D1 to D6) using an PIC18F4550 microcontroller. The code uses pins B0, B1 and B2 to control the LEDs, turning one on for 1 second while turning the others off, in the sequence of D1, D2, D3, D4, D5 and D6. The code and its simulation, showing each LED turning on individually while the others remain off, are included.

Uploaded by

P8YCG9PW64
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 PDF, TXT or read online on Scribd
You are on page 1/ 5

Montes Pacheco Juan Carlos Universidad Autónoma de Querétaro

HW#: 4 Facultad de Ingeniería

Date: 16 of February of 2011 Digital Systems 2

Create and simulate a code to turn on or off the six LEDs of the figure 1, one each time with
the sequence D1, D2, D3, D4, D5, D6.

Figure 1. Electric circuit of the sequence.

CODE

// Sequence of 5 LEDs turned on or off, one each time. Using pins b0, b1 and b2.

# INCLUDE<18F4550.H> //directives
# FUSES XT, NOWDT, NOPROTECT
# USE DELAY(CLOCK = 4 MHZ)

void main() { //main function


// infinite loop
while(true){

output_low(pin_b0); //led 1 turned on, 2,3,4,5,6 turned off


output_high(pin_b1);
output_float(pin_b2);
delay_ms(1000); // wait for 1 second

output_high(pin_b0); //led 2 turned on, 1,3,4,5,6 turned off


output_low(pin_b1);
delay_ms(1000); // wait for 1 second

output_float(pin_b0); //led 3 turned on, 1,2,4,5,6 turned off


output_low(pin_b1);
output_high(pin_b2);
delay_ms(1000); // wait for 1 second
output_high(pin_b1); //led 4 turned on, 1,2,3,5,6 turned off
output_low(pin_b2);
delay_ms(1000);

output_low(pin_b0); //led 5 turned on, 1,2,3,4,6 turned off


output_float(pin_b1);
output_high(pin_b2);
delay_ms(1000); // wait for 1 second

output_high(pin_b0); //led 6 turned on, 1,2,3,4,5 turned off


output_low(pin_b2);
delay_ms(1000); // wait for 1 second
}} //end of the program

SIMULATION
In next images, we can see each LED turned on and the others turned off starting from D1 to D6.
The pins used are b0, b1 and b2.

LED D1 on and off others.


LED D2 on and off others.

LED D3 on and off others.


LED D4 on and off others.

LED D5 on and off others.


LED D6 on and off others.

You might also like