Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(A0,A1,A2 ,A3 ,A4, A5);
- byte d=0;
- byte x=0,xx;
- byte mills,mins,sec;
- void setup()
- {
- sec=0;
- mills=0;
- mins=0;
- lcd.begin(16,2);
- lcd.clear();
- //Serial.begin(9600); //For Serial Prints
- TCCR1A=0x00; ///Timer 1 normal mode
- TCCR1B=0x00; /// Timer 1 off
- TCNT1=0xF9E6; /// Timer 1 preset value 1/10 sec
- bitWrite(SREG,7,1); /// Enable global interrupt
- bitWrite(TIMSK1,0,1); /// Enable TIMER1_OVF interrupt
- TCCR1B=0x05; /// Timer 1 ON
- }
- ISR(TIMER1_OVF_vect)
- {
- TCCR1B=0x00; /// Timer 1 off
- TCNT1=0xF9E6;
- mills=mills+1;
- xx=xx-1;
- if(mills>9)
- {
- sec=sec+1;
- mills=0;
- }
- if(sec>59)
- {
- mins=mins+1;
- mills=0;
- sec=0;
- }
- x=x+1;
- bitSet(TIFR1,2); /// TOV1 Clear
- TCCR1B=0x05; /// Timer 1 ON
- interrupts();
- lcd.clear();
- lcd.setCursor(1,0);
- lcd.println("MIN:SEC:SEC/10");
- lcd.setCursor(4,1);
- lcd.print(mins,DEC);
- lcd.print(":");
- lcd.print(sec,DEC);
- lcd.print(":");
- lcd.print(mills,DEC);
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement