Alx09

SBMM

Apr 17th, 2021
830
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2.  
  3. const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
  4. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  5.  
  6. unsigned short secunde, miliSecunde, minute, ore;
  7. unsigned long int k=0;
  8.  
  9. void setup()
  10. {
  11.   DDRD|=0xFF;
  12.   lcd.begin(16, 2);
  13.   TIMSK2=0x01; // validare intrerupere de la Timer 0 Overflow
  14.   TCCR2A=0x00; // setare mod normal
  15.   TCCR2B=0x06;
  16.  
  17.  
  18. }
  19. void Print0(unsigned short nr){
  20.  if(nr < 10) lcd.print('0');
  21. }
  22.  
  23. void loop(){
  24.   Print0(ore);
  25.   lcd.print(ore);
  26.   lcd.print(':');
  27.   Print0(minute);
  28.   lcd.print(minute);
  29.   lcd.print(':');
  30.   Print0(secunde);
  31.   lcd.print(secunde);
  32.  
  33.   delay(1000);
  34.   lcd.clear();
  35. }
  36.  
  37. ISR(TIMER2_OVF_vect){
  38.     k++;
  39.   if(k == 240){
  40.     ++secunde;
  41.      k =0;
  42.   }
  43.   if(secunde > 59){
  44.     ++minute;
  45.     secunde = 0;
  46.   }
  47.   if(minute > 59){
  48.    ++ore;
  49.     minute = 0;
  50.   }
  51.   if(ore == 24) ore = 0;
  52. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×