PIC16F877A – MIKRO C – ADC

Photo of author

By Jackson Taylor

Home » Programming » PIC16F877A – MIKRO C – ADC

Here anolog value reads from channel 0 and it will display on the LCD

void main()
{
    float i;
    char a[13];
    adcon1=0x80;
    lcd_init(&portd);
    lcd_cmd(lcd_cursor_off);
    while(1)
    {
        i=adc_read(0)*.00488;
        floattostr(i,a);
        lcd_out(1,1,a);
        lcd_out(1,5,"        ");
        delay_ms(500);
    }
}

The value written to ADCON1 is hexadecimal: 0x80 is 1000 0000 in binary, so only the top bit is set. A hex to binary converter makes it easy to check which register bits a value like this sets, and the hex to decimal tool gives the plain number (0x80 = 128).

See also
SCROLLING DISPLAY USING PIC ONLY IN MIKRO C

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works