// PIC16F690 in C - Versione 0.2c - Dicembre 2009 // Copyright (c) 2009, 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/PIC16F690 #include #define _XTAL_FREQ 8000000 // Used from delay macro __CONFIG(INTIO & // Use internal clock WDTDIS & // Disable watchdog PWRTEN & // Delay after power on enabled MCLRDIS & // Internal External Switch Over Mode Disable UNPROTECT & // Disable memory protection BORDIS & // Disable reset on low volage IESODIS & // Internal External Switch Over Mode Disable FCMDIS); // Disable Fail clock monitoring void main(void) { OSCCON=0x70; // x111 0000 - 8 Mhz internal clock TRISC = 0x00; // Set PORTC as Output // TRISA = 0xFF; // Set PORTA as input (RA3 is always input if MCLR disabled) ANSEL = 0; // Set as Digital I/O ANSELH = 0; // Set as Digital I/O for(;;) { // while (RA3); // Loop if pin 3 of PORTA is 1 (SW1 not pressed) PORTC = 0x01; // xxxx 0001 - Turn On Port RC0 __delay_ms(98); // Delay 98 ms PORTC = 0x02; // xxxx 0010 - Turn On Port RC1 __delay_ms(98); // Delay 98 ms PORTC = 0x04; // xxxx 0100 - Turn On Port RC2 __delay_ms(98); // Delay 98 ms PORTC = 0x08; // xxxx 1000 - Turn On Port RC3 __delay_ms(98); // Delay 98 ms PORTC = 0x04; // xxxx 0100 - Turn On Port RC2 __delay_ms(98); // Delay 98 ms PORTC = 0x02; // xxxx 0010 - Turn On Port RC1 __delay_ms(98); // Delay 98 ms } }