Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "TimerOne.h"
- byte hora = 0;
- int hora1 = 0;
- byte minu = 0;
- int minu1 = 0;
- byte segu = 0;
- int segu1 = 0;
- unsigned long tempo = 0;
- //---------------------------------
- void setup()
- {
- Serial.begin(9600);
- pinMode(13, OUTPUT);
- Timer1.initialize(1000000); // initialize timer1, and set a 1 second period
- Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
- }
- //--------------------------------------
- void callback()
- {
- digitalWrite(13, digitalRead(13) ^ 1);
- tempo++;
- }
- //--------------------------------------
- void loop()
- {
- hora = tempo / 3600;
- hora1 = hora * 3600;
- minu1 = tempo - hora1;
- minu = minu1/60;
- segu1 = minu*60 + hora1;
- segu = tempo - segu1;
- Serial.print(hora);
- Serial.print(":");
- Serial.print(minu);
- Serial.print(":");
- Serial.println(segu);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement