Advertisement
zujankaaa

Untitled

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