Monday, November 13, 2017

LED blinking - 2

Name: LED Blinking
Microcontroller: PIC16F877A
Description: This is very simple hello world poject.  All the pins of Port-C will be ON and OFF (one after one) with one second interval.

Code:
void main() 

portc=0;
trisc=0; //PortC pins are defined as output pin.
while(1)
        {
        portc=0b00000001;  // Only number one pin HIGH
        delay_ms(1000);
        portc=0b00000010;
        delay_ms(1000);
        portc=0b00000100;
        delay_ms(1000);
        portc=0b00001000;
        delay_ms(1000);
        portc=0b00010000;
        delay_ms(1000);
        portc=0b00100000;
        delay_ms(1000);
        portc=0b01000000;
        delay_ms(1000);
        portc=0b10000000;       // Only number eigth pin HIGH
        delay_ms(1000);
        }
}

No comments:

Post a Comment