Debian Codegraph @

examples/voltmeter.c

raw symbols SCIP
1 #include <avr/kp.h> // Include file for I/O operations
2
3 int main (void)
4 {
5 uint16_t data;
6 float v;
7
8 DDRB = 255; // Configure port B as output
9 adc_enable();
10 lcd_init();
11
12 while (1)
13 {
14 data = read_adc(0);
15 v = data * 5.0 / 1023;
16 PORTB = data >> 2; // convert 10 bit in to 8 bit
17 lcd_clear();
18 lcd_put_float(v, 3); // 3 decimals
19 delay_ms(500);
20 }
21 }