unsigned short one, two, three ;
unsigned char ch;
unsigned int adc_rd;
long tlong;
void main() {
INTCON = 0x20; // All interrupts disabled
ANSEL = 0x04; // Pin RA2 is configured as an analog input
TRISA = 0x04;
ANSELH = 0; // Rest of pins are configured as digital
TRISD = 0;
TRISE = 0;
ADCON1 = 0x82; // A/D voltage reference is VCC
TRISA = 0xFF; // All port A pins are configured as inputs
Delay_ms(500);
while (1) {
adc_rd = ADC_Read(2);
tlong = ((5000/1023)*(long)adc_rd)/10 ;
tlong = (tlong*2)+1000;
one = tlong / 1000;
two = (tlong / 100) % 10;
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?