MPLABXProjects\Singoki-2.X\Singoki02.c
 1 /*
 2  * File:   Singoki02.c
 3  * Author: Meito
 4  *    PIC12F683
 5  * Created on 2022/09/09, 10:28
 6  */
 7 
 8 // PIC12F683 Configuration Bit Settings
 9 // 'C' source line config statements
10 // CONFIG
11 #pragma config FOSC = INTOSCIO  // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
12 #pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
13 #pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
14 #pragma config MCLRE = OFF      // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
15 #pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
16 #pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
17 #pragma config BOREN = ON       // Brown Out Detect (BOR enabled)
18 #pragma config IESO = OFF       // Internal External Switchover bit (Internal External Switchover mode is disabled)
19 #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
20 
21 // #pragma config statements should precede project file includes.
22 // Use project enums instead of #define for ON and OFF.
23 
24 #include <xc.h>
25 
26 void main(void) {
27     OSCCON = 0x40;
28     ANSEL = 0;
29     CMCON0 = 0x07;
30     TRISIO = 0b00001100;
31     
32     while(1){
33         if(GP2==1){
34             GP0=1;
35             GP1=0;
36             GP4=1;
37             GP5=0;
38         } else if(GP3==1){
39             GP0=0;
40             GP1=1;
41             GP4=0;
42             GP5=1;
43         } else {
44             GP0=0;
45             GP1=1;
46             GP4=1;
47             GP5=0;
48         }
49     }
50 }
51