Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. #include <LiquidCrystal.h>
  4.  
  5. const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
  6. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  7.  
  8. void setup()
  9. {
  10.  
  11. lcd.begin(16, 2);
  12.  
  13. pinMode(LED_BUILTIN, OUTPUT);
  14.  
  15. // initialize Timer1
  16. cli(); // disable global interrupts
  17. TCCR1A = 0; // set entire TCCR1A register to 0
  18. TCCR1B = 0; // same for TCCR1B
  19.  
  20. // set compare match register to desired timer count:
  21. OCR1A = 15624;
  22. // turn on CTC mode:
  23. TCCR1B |= (1 << WGM12);
  24. // Set CS10 and CS12 bits for 1024 prescaler:
  25. TCCR1B |= (1 << CS10);
  26. TCCR1B |= (1 << CS12);
  27. // enable timer compare interrupt:
  28. TIMSK1 |= (1 << OCIE1A);
  29. // enable global interrupts:
  30. sei();
  31. }
  32.  
  33. void loop()
  34. {
  35. }
  36.  
  37. ISR(TIMER1_COMPA_vect)
  38. {
  39. digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  40. lcd.setCursor(0, 1);
  41. // print the number of seconds since reset:
  42. lcd.print(millis() / 1000);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement