// PIC18F14K50 in C - Versione 0.1 - Aprile 2010 // Copyright (c) 2010, VincenzoV.net // Creative Commons | Attribuzione-Condividi allo stesso modo 3.0 Unported. // Creative Commons | Attribution-Share Alike 3.0 Unported // https://www.vincenzov.net/tutorial/elettronica-di-base/PIC18F14K50 #include #include #pragma config FOSC = IRCCLKOUT // Internal RC oscillator (F/4 to OSC2) // #pragma config FOSC = IRC // Internal RC oscillator #pragma config WDTEN = OFF // Watchdog disabled #pragma config LVP = OFF // Disable Low Voltage Programming #pragma config MCLRE = OFF // Disable MCLR void main (void) { TRISC = 0x00; // Set PORTC as Output // OSCCON = 0x70; // Select 16 MHz internal clock (default 1MHz) //TRISA = 0xFF; // Set PORTA as input (RA3 is always input if MCLR disabled) for(;;) { while (!PORTAbits.RA3); // Loop if pin 3 of PORTA is 1 (SW1 not pressed) PORTC = 0x01; // xxxx 0001 - Turn On Port RC0 Delay1KTCYx(100); // Delay 100.000 Timer cycle (400 ms @ 1MHz) PORTC = 0x02; // xxxx 0010 - Turn On Port RC1 Delay1KTCYx(100); // Delay 100.000 Timer cycle PORTC = 0x04; // xxxx 0100 - Turn On Port RC2 Delay1KTCYx(100); // Delay 100.000 Timer cycle PORTC = 0x08; // xxxx 1000 - Turn On Port RC3 Delay1KTCYx(100); // Delay 100.000 Timer cycle PORTC = 0x04; // xxxx 0100 - Turn On Port RC2 Delay1KTCYx(100); // Delay 100.000 Timer cycle PORTC = 0x02; // xxxx 0010 - Turn On Port RC1 Delay1KTCYx(100); // Delay 100.000 Timer cycle } }