how to get analog inputs PIC 18F in mikro C ?

Thread Starter

pw123

Joined Mar 7, 2010
1
hi all,

i want to get Anlog inputs in to a PIC 18 F,im new in mikro C.

and i want to convert these anlog inputs into digital .please advice me.

and please provide me a learning PDF link for mikro c for PIC 18 f.

THANKS.
 

symqwerty

Joined Feb 22, 2010
31
MikroC have built-in function for that purpose ( ADC )

From mikroC menubar -> goto help

From the help page, read ADC chapter


Sample code:
Rich (BB code):
unsigned short adc_val ;  // use to store digital value
void main ()
{
 ADCON1 = 0x00;    // check PIC18 datasheet and set particular bits for ADC
 ADCON0 = 0x00;    // same as above   
TRISA = 0xff ;       // set portA as input
 TRISB = 0;
 while (1)
     {
          adc_val = adc_read(0) ; //adc_read(x) is mikroC built-in func while x is 
                                 // port number. Eg, read from AD0 pin
         portb =adc_val ;           // for you to figure out:)
     }
}
 
Top