#include <pic.h>
char i;
void delay(unsigned int cnt) { while(cnt--); }
void main(void) { ANSEL = 0x00; // Analog Input : Disable
TRISC = 0X00; PORTC = 0X00; // 0b00000000;
while(1) { PORTC = 0xff; // 0x01 delay(15000); PORTC = 0x00; // 0x01 delay(15000); } } |
777 |
#include <pic.h>
char i;
void delay(unsigned int cnt) { while(cnt--); }
void main(void) { ANSEL = 0x00; // Analog Input : Disable
TRISC = 0X00; PORTC = 0X00; // 0b00000000;
while(1) { PORTC = 0b00000001; // 0x01 delay(15000); PORTC = 0b00000010; // 0x02 delay(15000); PORTC = 0x04; delay(15000); PORTC = 0x08; delay(15000); PORTC = 0x10; delay(15000); PORTC = 0x20; delay(15000); PORTC = 0x40; delay(15000); PORTC = 0x80; delay(15000); PORTC = 0b01000000; //0x40 delay(15000); PORTC = 0x20; delay(15000); PORTC = 0x10; delay(15000); PORTC = 0x08; delay(15000); PORTC = 0x04; delay(15000); PORTC = 0x02; delay(15000);
} } |
|
#include <pic.h> char i; void delay(unsigned int cnt) { while(cnt--); } void main(void) { ANSEL = 0x00; // Analog Input : Disable TRISC = 0X00; PORTC = 0X01; // 0b00000000; while(1) { for(i=0; i<7; i++) { delay(20000); PORTC <<= 1; } PORTC = 0x01; } }
|
LED°¡
|
#include <pic.h>
unsigned char i; ad_result;
void delay(unsigned int cnt) { while(cnt--); }
void main(void) { ANSEL = 0x01; // AN0 : Analog Input : Enable // ANS0 = 1;
TRISC = 0X00; PORTC = 0X01; // 0b00000000;
CHS2 = 0; CHS1 = 0; CHS0 = 0; // AN0 ---> ADC ¸ðµâ¿¡ ¿¬°á (MUX) VCFG = 0; // Vref+ --> VDD(5V) ADON = 1; // ADC Module Enable ADFM = 0; // Left Justifided XXXXXXXX XX------ while(1) { GODONE = 1; // ADC Start
while(GODONE); // Check ADC Ending ?
ad_result = ADRESH; // °á°ú°ªÀúÀå
PORTC = ad_result >> 1; } }
|
Analog TEST
|
#include <pic.h>
__CONFIG(INTOSCIO & MCLRDIS & WDTDIS);
unsigned char i; ad_result; tmr_65ms;
void delay(unsigned int cnt) { while(cnt--); }
void main(void) { ANSEL = 0x01; // AN0 : Analog Input : Enable // ANS0 = 1;
TRISC = 0X00; PORTC = 0X01; // 0b00000000;
T0CS = 0;
CHS2 = 0; CHS1 = 0; CHS0 = 0; // AN0 ---> ADC ¸ðµâ¿¡ ¿¬°á (MUX) VCFG = 0; // Vref+ --> VDD(5V) ADON = 1; // ADC Module Enable ADFM = 0; // Left Justifided XXXXXXXX XX------
PSA = 0; PS2 = 1; PS1 = 1; PS0 = 0; // Fcy= 1MHz, Tcy =iuS, everty 256*2*Try*256
while(1) {
while(T0IF==0); T0IF = 0; // Cleared by softwear
tmr_65ms++; if(tmr_65ms > 10) { tmr_65ms = 0; RC0 ^=1 ; }
} }
|
? |
#include <pic.h>
__CONFIG(INTOSCIO & MCLRDIS & WDTDIS);
unsigned char i; ad_result; tmr_65ms;
void delay(unsigned int cnt) { while(cnt--); }
void main(void) { ANSEL = 0x01; // AN0 : Analog Input : Enable // ANS0 = 1;
TRISC = 0X00; PORTC = 0X01; // 0b00000000;
T0CS = 0;
CHS2 = 0; CHS1 = 0; CHS0 = 0; // AN0 ---> ADC ¸ðµâ¿¡ ¿¬°á (MUX) VCFG = 0; // Vref+ --> VDD(5V) ADON = 1; // ADC Module Enable ADFM = 0; // Left Justifided XXXXXXXX XX------
PSA = 0; PS2 = 1; PS1 = 1; PS0 = 0; // Fcy= 1MHz, Tcy =iuS, everty 256*2*Try*256
while(1) {
while(T0IF==0); // 0À̳ÄÇÏ°í ºñ±³ T0IF = 0; // Cleared by softwear
tmr_65ms++; if(tmr_65ms > 10) { tmr_65ms = 0; RC0 ^=1 ; tmr_65ms = 0; RC2 ^=1 ;
}
|
? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|