Advertisement
gabrielaozegovic

10 - 3

Jan 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1.  
  2. #define F_CPU 7372800UL
  3.  
  4. #include <avr/io.h>
  5. #include <avr/interrupt.h>
  6. #include <util/delay.h>
  7. #include <stdlib.h>
  8. #include "lcd.h"
  9.  
  10. void write2lcd(uint16_t adc){
  11. char str[16];
  12. itoa(adc, str, 10);
  13. lcd_clrscr();
  14. lcd_puts(str);
  15. }
  16.  
  17. ISR(ADC_vect){
  18. uint16_t val = ((ADC * 5.0/1024) - 0.5) * 1000/10;
  19. write2lcd(val);
  20. _delay_ms(500);
  21. }
  22.  
  23. int main(void){
  24.  
  25.  
  26. DDRD = _BV(4);
  27.  
  28. TCCR1A = _BV(COM1B1) | _BV(WGM10);
  29. TCCR1B = _BV(WGM12) | _BV(CS10);
  30. OCR1B = 20;
  31.  
  32. TCCR0 = _BV(WGM01) | _BV(CS00) | _BV(CS02);
  33. OCR0 = 180;
  34. TIMSK = _BV(OCIE0);
  35.  
  36. sei();
  37.  
  38. //INICIJALIZACIJA
  39. ADMUX = _BV(REFS0); //pomak za kanal
  40. ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS2) | _BV(ADPS0);
  41. SFIOR = _BV(ADTS1) | _BV(ADTS0);
  42.  
  43.  
  44. lcd_init(LCD_DISP_ON);
  45. lcd_clrscr();
  46.  
  47. lcd_gotoxy(7, 0);
  48. lcd_puts("kys");
  49.  
  50.  
  51. while (1) {
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement