| 1 | #include <avr/kp.h> // Include file for I/O operations |
| 2 | #include <stdlib.h> // include the utoa() function prototype |
| 3 | |
| 4 | |
| 5 | int main (void) |
| 6 | { |
| 7 | uint16_t data; |
| 8 | char a[6], *p; |
| 9 | |
| 10 | DDRB = 255; // Configure port B as output |
| 11 | adc_enable(); |
| 12 | uart_init(38400); |
| 13 | |
| 14 | while (1) |
| 15 | { |
| 16 | data = read_adc(0); |
| 17 | PORTB = data >> 2; // convert 10 bit in to 8 bit |
| 18 | utoa(data, a, 10); // convert to ASCII string |
| 19 | p = a; |
| 20 | while(*p) uart_send_byte(*p++); |
| 21 | uart_send_byte('\n'); |
| 22 | delay_ms(500); |
| 23 | } |
| 24 | } |