Advertisement
Guest User

Untitled

a guest
May 29th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3. #include "hd44780.h"
  4.  
  5. uint16_t pomiar(uint8_t kanal);
  6.  
  7. int main(void)
  8. {
  9.    LCD_Initalize();
  10.  
  11.    ADMUX |= (1<<REFS0) | (1<<REFS1);
  12.    ADCSRA |= (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0);
  13.  
  14.  
  15.    while(1)
  16.    {
  17.        LCD_Clear();
  18.        LCD_WriteText(pomiar(5));
  19.        _delay_ms(1000);
  20.    }
  21. }
  22.  
  23. uint16_t pomiar(uint8_t kanal)
  24. {
  25.     ADMUX = (ADMUX & 0xF8) | kanal;
  26.     ADCSRA |= (1<<ADSC);
  27.  
  28.     while(ADCSRA & (1<<ADSC));
  29.  
  30.     return ADCW;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement