Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <LiquidCrystal.h>
- const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- void setup()
- {
- lcd.begin(16, 2);
- pinMode(LED_BUILTIN, OUTPUT);
- // initialize Timer1
- cli(); // disable global interrupts
- TCCR1A = 0; // set entire TCCR1A register to 0
- TCCR1B = 0; // same for TCCR1B
- // set compare match register to desired timer count:
- OCR1A = 15624;
- // turn on CTC mode:
- TCCR1B |= (1 << WGM12);
- // Set CS10 and CS12 bits for 1024 prescaler:
- TCCR1B |= (1 << CS10);
- TCCR1B |= (1 << CS12);
- // enable timer compare interrupt:
- TIMSK1 |= (1 << OCIE1A);
- // enable global interrupts:
- sei();
- }
- void loop()
- {
- }
- ISR(TIMER1_COMPA_vect)
- {
- digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
- lcd.setCursor(0, 1);
- // print the number of seconds since reset:
- lcd.print(millis() / 1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement