Minggu, 22 Januari 2012

Beranda » PIC Tutorial Series-Led Blinking Project For PIC Microcontrollers

PIC Tutorial Series-Led Blinking Project For PIC Microcontrollers

It turns on/off LEDs connected to
     PORTA, PORTB, PORTC and PORTD
void main() {

  ANSEL  = 0;            // Configure AN pins as digital
  ANSELH = 0;
  C1ON_bit = 0;          // Disable comparators
  C2ON_bit = 0;

  TRISA = 0x00;          // set direction to be output
  TRISB = 0x00;          // set direction to be output
  TRISC = 0x00;          // set direction to be output
  TRISD = 0x00;          // set direction to be output
 
  do {
    PORTA = 0x00;        // Turn OFF LEDs on PORTA
    PORTB = 0x00;        // Turn OFF LEDs on PORTB
    PORTC = 0x00;        // Turn OFF LEDs on PORTC
    PORTD = 0x00;        // Turn OFF LEDs on PORTD
    Delay_ms(1000);      // 1 second delay
   
    PORTA = 0xFF;        // Turn ON LEDs on PORTA
    PORTB = 0xFF;        // Turn ON LEDs on PORTB
    PORTC = 0xFF;        // Turn ON LEDs on PORTC
    PORTD = 0xFF;        // Turn ON LEDs on PORTD
    Delay_ms(1000);      // 1 second delay
  } while(1);            // Endless loop
}

Tidak ada komentar:

Posting Komentar

Diberdayakan oleh Blogger.