fork download
  1. #include <xc.h> // include processor files
  2.  
  3. // Configuration bits for PIC16F877A
  4. #pragma config FOSC = XT // Oscillator Selection
  5. #pragma config WDTE = OFF // Watchdog Timer Enable
  6. #pragma config PWRTE = ON // Power-up Timer Enable
  7. #pragma config BOREN = ON // Brown-out Reset Enable
  8. #pragma config LVP = OFF // Low-Voltage Programming Enable
  9. #pragma config CPD = OFF // Data EEPROM Memory Code Protection
  10. #pragma config WRT = OFF // Flash Program Memory Write Enable
  11. #pragma config CP = OFF // Flash Program Memory Code Protection
  12.  
  13. #define _XTAL_FREQ 4000000 // Define system clock for delay functions
  14.  
  15. void main() {
  16. TRISB = 0x00; // Set PORTB as output
  17.  
  18. while (1) {
  19. PORTB = 0xFF; // Turn on all LEDs on PORTB
  20. __delay_ms(500); // 500 ms delay
  21. PORTB = 0x00; // Turn off all LEDs
  22. __delay_ms(500); // 500 ms delay
  23. }
  24. }
  25.  
Success #stdin #stdout 0.03s 25776KB
stdin
Standard input is empty
stdout
#include <xc.h> // include processor files

// Configuration bits for PIC16F877A
#pragma config FOSC = XT // Oscillator Selection
#pragma config WDTE = OFF // Watchdog Timer Enable
#pragma config PWRTE = ON // Power-up Timer Enable
#pragma config BOREN = ON // Brown-out Reset Enable
#pragma config LVP = OFF // Low-Voltage Programming Enable
#pragma config CPD = OFF // Data EEPROM Memory Code Protection
#pragma config WRT = OFF // Flash Program Memory Write Enable
#pragma config CP = OFF // Flash Program Memory Code Protection

#define _XTAL_FREQ 4000000 // Define system clock for delay functions

void main() {
    TRISB = 0x00; // Set PORTB as output

    while (1) {
        PORTB = 0xFF; // Turn on all LEDs on PORTB
        __delay_ms(500); // 500 ms delay
        PORTB = 0x00; // Turn off all LEDs
        __delay_ms(500); // 500 ms delay
    }
}