Interfacing LEDs with PIC18F1220 Microcontroller
Pins Diagram:
In this tutorial, I'll show you how to interface 3 LEDs with the PIC18F1220 Microcontroller.
Proteus Circuit Diagram:
MikroC Code:
//Code by Shahid Khan
//Interfacing LEDs
sbit LEDGREEN at PORTB.B4; // LED at pin 4 portB
sbit LEDRED at PORTB.B5; // LED at pin 5 portB
sbit LEDYELLOW at PORTB.B6; // LED at pin 6 portB
void main() {
TRISB.RB4 = 0; //output
TRISB.RB5 = 0; //output
TRISB.RB6 = 0; //output
while(1) //loop
{
LEDGREEN = 1;
Delay_ms(50);
LEDRED = 1;
Delay_ms(50);
LEDYELLOW = 1;
Delay_ms(300);
LEDYELLOW = 0;
Delay_ms(50);
LEDRED = 0;
Delay_ms(50);
LEDGREEN = 0;
Delay_ms(300);
}
}
Simulation Video:
In this tutorial, I'll show you how to interface 3 LEDs with the PIC18F1220 Microcontroller.
Proteus Circuit Diagram:
MikroC Code:
//Code by Shahid Khan
//Interfacing LEDs
sbit LEDGREEN at PORTB.B4; // LED at pin 4 portB
sbit LEDRED at PORTB.B5; // LED at pin 5 portB
sbit LEDYELLOW at PORTB.B6; // LED at pin 6 portB
void main() {
TRISB.RB4 = 0; //output
TRISB.RB5 = 0; //output
TRISB.RB6 = 0; //output
while(1) //loop
{
LEDGREEN = 1;
Delay_ms(50);
LEDRED = 1;
Delay_ms(50);
LEDYELLOW = 1;
Delay_ms(300);
LEDYELLOW = 0;
Delay_ms(50);
LEDRED = 0;
Delay_ms(50);
LEDGREEN = 0;
Delay_ms(300);
}
}
Simulation Video:
Post a Comment