pnjbtr
Full Member level 5
Code below i obtained from an other web site.
Can some one explain about this code.
This program is for pic 16F676 and it display led at RA4 and RA5.
RA0 is for analog input.
In this code,there is no detail in front of each instruction.
For example,
TRISA0=1; // Port A0 is input
--------------------------------------------------------------------
Can some one explain about this code.
This program is for pic 16F676 and it display led at RA4 and RA5.
RA0 is for analog input.
In this code,there is no detail in front of each instruction.
For example,
TRISA0=1; // Port A0 is input
--------------------------------------------------------------------
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 #include<htc.h> #include<pic.h> __CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & BOREN_OFF & CP_OFF & CPD_OFF); void main() { unsigned int x=0; GIE=0; PEIE=0; TRISA0=1; TRISC4=0; TRISC5=0; RC4=1; RC5=1; ANSEL=0; ADCON1=0x01<<4; ADCON0=(0x80)+1; ADIE=0; ADIF=0; //while(1) { ADRESH=0; ADRESL=0; x=0; GO_DONE=1; while(GO_DONE==1) {} x=(ADRESH<<8)+ADRESL; x&=0x03FF; if( x < 270) { RC4=1; } if(x>270 ) { if(x<=370) { RC5=0; } } if(x > 370) { RC4=0; RC5=0; } } while(1) {} }
Last edited by a moderator: