Ajith Kumar B
Published © GPL3+

Digital Clock with IR Remote Control using Arduino Nano

Digital Clock With Hour/Minute/Second/ Temperature display and features Alarm/snooze/Hour Chime with a full function IR remote Control.

BeginnerFull instructions provided997
Digital Clock with IR Remote Control using Arduino Nano

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
DS3231MPMB1 Peripheral Module
Maxim Integrated DS3231MPMB1 Peripheral Module
×1
1 inch common Anode Seven segment Display
×4
1/2 inch Common anode seven segment display
×2
3 mm LED
×2
Copper clad phenolic board 15 X 20 cm
×1
Infra red receiver TSOP1738
×1
UM 66 music generator IC
×1
Continuous tone piezo buzzer
×1
2 inch small speaker 8 ohm , 0.5 w
×1
Female edge connector for mounting Arduino ( 40 pin)
×1
Resistor 220 Ohm ¼ w
×1
Resistor 150 Ohm ¼ w
×8
Resistor 100 Ohm ¼ w
×1
IR Remote control unit
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

DETAILS OF CONSTRUCTION

Schematics

CIRCUIT DIAGRAM

PIN CONFIGURATION

Code

SKETCH OF THE PROJECT

Arduino
//COMPLETE DIGITAL CLOCK WITH INFRARED REMOTE CONTROL BY AJITH KUMAR 
int digit1 = A3;
int digit2 = 9;
int digit3 = 10;
int digit4 = 12;
int digit6 = 13;
int digit5 = A2;
int segA = 4;
int segB = 5;
int segC = 8;
int segD = 7;
int segE = 6;
int segF = 3;
int segG = 2;
int Dot = 1;
int Hrchime = A1;
int Almout   = A0;
int Disp_mode = 0;
int aset;
int aset1 = 3;        // set value as 3  for first time retrival of alarm set
int HCperiod = 12;    // required time for hour chime in seconds
int snoozperiod = 5; // required time to repeat alarm snooz in minutes
int almperiod = 20;  // maximum time of alarm ringing before auto off
int dtt2;
int snoozflag = 0;
int snoozset = 0;
int setmode = 0;
int dispoff_flag = 1;
int keyx;
int count = 0;
int keysum;
int keysum1;
int keyvalid;
int set_mode = 0;
int time_set  = 0 ;
int alm_set;
int alm_set1;
int charshow1;
int charshow2;
int timp2;
int typeset  = 0;
int beep_onoff = 0;

static unsigned int altim;
static unsigned int altim1;
unsigned long key_value = 0;


//#include <Wire.h>
#include "RTClib.h"
#include <EEPROM.h>
#include <IRremote.h>


#define RECEIVER_PIN 11
#define EEADDR 174 // Start location to write EEPROM data.
#define EEADDR1 188
RTC_DS3231 RTC;
IRrecv receiver(RECEIVER_PIN);
decode_results results;

void ShowNumber(int );
void displaychar(int , int);
void Light_HR_MIN(int);
void displaysecond(int );
void IRR(int  , int);
void ALARMSTORE(int , int);

//==========================================================================================================
void setup() {
  //Serial.begin(9600);

  RTC.begin();
  DateTime now = RTC.now();
  //RTC.adjust(DateTime(__DATE__, __TIME__));// for setting clock   remove // from this line  and upload sketch
  //after setting clock again put // on the line and upload once more

  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(Dot,  OUTPUT);
  pinMode(Hrchime, OUTPUT);
  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  pinMode(digit5, OUTPUT);
  pinMode(digit6, OUTPUT);
  pinMode(Almout, OUTPUT);
  digitalWrite(Almout, LOW);
  digitalWrite(Hrchime, LOW);
  digitalWrite(Almout, LOW);

 
   // ------------------------------retrieving alarm set time from flash on power_on

  int EEAddr = EEADDR;
  int EEAddr1 = EEADDR1;
  if (aset1 == 3  ) {

    EEPROM.get(EEAddr , altim); EEAddr += sizeof(altim);
    EEPROM.get(EEAddr1 , altim1); EEAddr1 += sizeof(altim1);
    alm_set = altim1 * 100 + altim;
    aset1 = 6;
    aset  = 7;
    alm_set1 = alm_set;
  }
  else {}

  //-------end of alrm set time reading from flash

  receiver.enableIRIn(); // enable the receiver
  int IRR(int);
}

//========================================END OF SETUP===================================

void loop() { // ==========================VOID LOOP=====================================



  //====================================DISPLAY OFF FUNCTION.==============================
  if ( dispoff_flag == 0) {
    digitalWrite(digit1, LOW);
    digitalWrite(digit2, LOW);
    digitalWrite(digit3, LOW);
    digitalWrite(digit4, LOW);
    digitalWrite(digit5, LOW);
    digitalWrite(digit6, LOW);
  }
  else {

    //=================================TEMPERATURE DISPLAY ====================================

 if (Disp_mode == 4) {
      float tempC = RTC.getTemperature();
            tempC = tempC * 100;

      for (int i = 8 ; i > 0  ; i--) {
          Light_HR_MIN(tempC);
          displaychar(16 , 15) ;
          }

 }
 else{}

     //=================================REAL TIME DISPLAY========================================

    if (Disp_mode == 0) {

      DateTime now = RTC.now();
      int tim = (now.hour());

      if (tim >  12) {
        tim = tim - 12;
      }
      else;
      if (tim ==  0) {
        tim = 12;
      }
      else;
      int timp = (tim * 100 + now.minute());
      int timp1 = now.second();
      timp2 = (now.hour() + now.minute());


      // For Digits display
      for (int i = 10
                   ; i > 0  ; i--) {
        Light_HR_MIN(timp);
        displaysecond(timp1);
      }
    }

    else {}

  }
  //-------------------------------------------------------------------------------------------
  //===============================CHECKING REMOTE PESSING=====================================

  if  (receiver.decode(&results)) {

    //Serial.println("KEY RESULT");  // remove //  of this line and next line to find the ir code of an unknown IR receiver
    // Serial.println(results.value, HEX);



    if (results.value == 0x1FE7887) { //=======TEMPERATURE  DIDPLAY KEY  PRESSED==============
    Disp_mode = 4;
     }
    else
    { receiver.resume();
  }

//=============================================RETURN KEY PRESSED=============================
 if (results.value == 0x1FE58A7) {

          typeset = 0;
           Disp_mode = 0;
 }
 //===========================================================================================

      if (results.value == 0x1FE40BF) {  //=========== ALARM SET KEY PRESSED==================
        typeset = 1;
        setmode = 0;
        //almblow=0;
       Disp_mode = 1;
        keysum1 = alm_set;

        IRR( keysum1 , 1);
        receiver.resume();
        alm_set = keysum1;

        ALARMSTORE(alm_set , 1 );
        aset = 6;

      }
      else {

        typeset = 0;
       Disp_mode == 0;
      }

      //==========================================================================================

      if (results.value == 0x1FEC03F) { // ============== TIME SET KEY PRESSED====================
        typeset = 2;
        setmode = 1;

        Disp_mode = 1;
        DateTime now = RTC.now();
        dtt2 = now.hour() * 100 + now.minute();

        IRR( dtt2 , 2);
        receiver.resume();

        //Serial.println("    ");

        //Serial.print("TIME  SET=  ");

        //Serial.println(keysum1);
        int newtime = keysum1;
        int h1 = newtime / 100;
        int m1 = newtime % 100;

        RTC.adjust(DateTime(2021, 1, 1, h1, m1, 0));

      }
      else {
        receiver.resume();
      }
      //=================================================================================================

      if (results.value == 0x1FEA05F) {  //===============ALARM OFF KEY PRESSED==========================

        Serial.print("ALM OFF  ");
        beep_onoff = 0;
        snoozflag = 0;
        //Serial.print(almblow);
      }
      else {
        receiver.resume();
      }

      //================================================================================================

      if (results.value == 0x1FE609F) {  //============ SNOOZ ON KEY PRESSED=============================
        delay(100);
        // Serial.print("SNOOZ ON  ");

        snoozset = snoozset + snoozperiod;
        snoozflag = 1;
        Serial.print("snooz on  ");
        Serial.print(snoozset);
        //digitalWrite(Almout, LOW);
        beep_onoff = 0;
      }
      else {
        receiver.resume();
      }
      //===================================================================================================


      if (results.value == 0x1FE48B7) { //============OFF/ ON KEY (DISPLAY OFF) KEY  PRESSED===============

        //Serial.print("display off OFF  ");
        //digitalWrite(Almout, LOW);
        dispoff_flag =  abs(dispoff_flag - 1);

        delay(500);
      }

      else {
        receiver.resume();
      }
    }

    //================================END OD REMOTE KEY PRESS CHECK=======================================
    // ==================================ALARM CHECKING====================================================
    DateTime now = RTC.now();
    int xc = now.hour() * 100 + now.minute();
    int yc = now.second();

    if (xc == alm_set  && yc == 1 ) {
      //digitalWrite(Almout, HIGH);
      snoozset = alm_set;
      beep_onoff = 1;

    }
    else {}

    if (snoozflag == 1) {

      if (xc == snoozset  && yc <= 1 ) {

        beep_onoff = 1;
        //digitalWrite(Almout, HIGH);
      }
      else {}
    }

    else {}

    if ( xc == alm_set + almperiod ) {
      //digitalWrite(Almout, LOW);

      beep_onoff = 0;
      snoozflag = 0;
    }
    else {}

    //===============================Alarm Beeping ===========================================================

    if (beep_onoff == 1 ) {


      if (yc % 2 == 0)
        digitalWrite(Almout, HIGH);
      else
        digitalWrite(Almout, LOW);
    }

    else

      digitalWrite(Almout, LOW);

    //========================================== hour chime===============================================


    int w1 = now.minute();
    int w2 = now.second();

    if (w1 == 0  &&  w2 <= HCperiod ) {
      digitalWrite(Hrchime, HIGH);
    }
    else {
      digitalWrite(Hrchime , LOW);
    }



  }  //=================================END OF MAIN LOOP VOID()==========================================

  //=============================SUB PROGRAMMES==========================================================


  void IRR( int keysum ,  int typeset ) {


    while (typeset != 0) {

      if (typeset == 1) {
        for (int i = 8 ; i > 0  ; i--) {

          Light_HR_MIN(keysum);
          displaychar(12 , 11) ;
          Light_HR_MIN(keysum);
        }
      }
      else {}

      if (typeset == 2) {
        for (int i = 8 ; i > 0  ; i--) {
          Light_HR_MIN(keysum);
          displaychar(13 , 14) ;
          Light_HR_MIN(keysum);
        }
      }
      else {}

      if  (receiver.decode(&results)) {


        switch (results.value) {

          case 0x1FE58A7://------------------------------RETURN KEY PRESSED--------------------------
            typeset = 0;
            Disp_mode = 0;
            break;

          //-----------------------------------------------------------------------------------------



          case 0x1FE20DF:  //  -----------------------PRESSING ENTER KEY----------------------------


            if (  keysum / 10 == 0 && keysum >= 60 ) {
              count = 0;
              keysum = 0;
              keyvalid = 0;
            }
            else {}

            if ( keysum / 100 == 0 && keysum >= 60) {
              count = 0;
              keysum = 0;
              keyvalid = 0;
            }
            else {}


            if ( keysum / 100 == 0 && keysum / 1000 == 0    &&   keysum % 100  >= 60   ) {
              count = 0;
              keysum = 0;
              keyvalid = 0;
            }
            else {}

            if ( keysum / 10000 == 0    &&  keysum % 100  >= 60  ) {
              count = 0;
              keysum = 0;
              keyvalid = 0;
            }
            else {
            }
            if (keyvalid == 1) {
              typeset = 0;
             Disp_mode = 0;
            }
            else {}

            break ;

          case 0x1FE50AF:  //..........KEY 1....
            keysum = keysum * 10 + keyx;
            count = count + 1;
            break;
          case 0x1FED827:   //........KEY 2.....
            keyx = 2;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break;
          case 0x1FEF807:   //........KEY 3 ....
            keyx = 3;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break;
          case 0x1FE30CF:    //........KEY 4.....
            keyx = 4;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FEB04F:   //........KEY 5.....
            keyx = 5;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FE708F:     //........KEY 6.....
            keyx = 6;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FE00FF:     //........KEY 7.....
            keyx = 7;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FEF00F:    //........KEY 8.....
            keyx = 8;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FE9867:    //........KEY 9.....
            keyx = 9;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;
          case 0x1FEE01F:     //........KEY 0.....
            keyx = 0;
            count = count + 1;
            keysum = keysum * 10 + keyx;
            break ;

        }  //
        //--------------------------------------------------------------------------
        if (count >= 5) {
          count = 0;
          keysum = 0;
        }
        else {}

        if (keysum >= 2400) {
          keysum = 0;
          count = 0;
        }
        else {}

        if (keysum <= 0) {
          keysum = 0;
          count = 0;
        }
        else {}

        key_value = results.value;
        keyvalid = 1;
        keysum1 = keysum;

        if (typeset == 1) {
          alm_set = keysum;

        }
        else {}

        if (typeset == 2) {
          time_set = keysum;
        }
        else {}

        delay(50);
        receiver.resume();
      }
    }
  }
  //============================================================================================
  void Light_HR_MIN(int toDisplay) {
#define BRIGHTNESS  1000
#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW
    int hrr = toDisplay / 100;

    if (Disp_mode == 1)
    { digitalWrite(digit5, LOW);
      digitalWrite(digit6, LOW);
    }
    else {}

    for (int digit = 4 ; digit > 0 ; digit--) {
      switch (digit) {

        case 1:
          if (hrr < 10  && hrr != 0 )
          {
            digitalWrite(digit1, DIGIT_OFF);
          }
          else {
            digitalWrite(digit1, DIGIT_ON);
          }
          break;
        case 2:
          digitalWrite(digit2, DIGIT_ON);
          break;
        case 3:
          digitalWrite(digit3, DIGIT_ON);
          break;
        case 4:
          digitalWrite(digit4, DIGIT_ON);
          break;
      }

      ShowNumber(toDisplay % 10);
      toDisplay /= 10;
      delayMicroseconds(BRIGHTNESS);
      ShowNumber(10);
      //Turn off all digits
      digitalWrite(digit1, DIGIT_OFF);
      digitalWrite(digit2, DIGIT_OFF);
      digitalWrite(digit3, DIGIT_OFF);
      digitalWrite(digit4, DIGIT_OFF);
    }
  }

  //=======================================================================
  void ShowNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

    switch (numberToDisplay) {
      case 0:

        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_OFF);

        break;
      case 1:
        digitalWrite(segA, SEGMENT_OFF);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_OFF);
        digitalWrite(segG, SEGMENT_OFF);
        break;
      case 2:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_OFF);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 3:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_OFF);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 4:
        digitalWrite(segA, SEGMENT_OFF);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 5:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 6:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 7:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_OFF);
        digitalWrite(segG, SEGMENT_OFF);
        break;
      case 8:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 9:
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
      case 10: //... FOR ALL DISP OFF
        digitalWrite(segA, SEGMENT_OFF);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_OFF);
        digitalWrite(segG, SEGMENT_OFF);
        break;


      case 11:  //------FOR SHOWING A
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;

      case 12:   // ------FOR SHOWING  L
        digitalWrite(segA, SEGMENT_OFF);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_OFF);
        break;

      case 13: //--- FOR SHOWING t
        digitalWrite(segA, SEGMENT_OFF);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;

      case 14: //------FOR SHOWING S
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_ON);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);

        break;

case 15: //------FOR SHOWING DEGREE SYMBOL
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_ON);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_OFF);
        digitalWrite(segE, SEGMENT_OFF);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_ON);
        break;
case 16: //------FOR SHOWING C
        digitalWrite(segA, SEGMENT_ON);
        digitalWrite(segB, SEGMENT_OFF);
        digitalWrite(segC, SEGMENT_OFF);
        digitalWrite(segD, SEGMENT_ON);
        digitalWrite(segE, SEGMENT_ON);
        digitalWrite(segF, SEGMENT_ON);
        digitalWrite(segG, SEGMENT_OFF);

        break;


    }
  }

  //===============================================================-
  void displaysecond(int sec) {
#define BRIGHTNESS 1000
#define BRIGHTNESS1  400

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);

    int yy = sec / 10;
    int aa = sec % 10;

    if (sec % 2 == 0 ) {
      digitalWrite(Dot, LOW);
      delayMicroseconds(BRIGHTNESS1);
    }
    else;
    { digitalWrite(Dot, HIGH);
      delayMicroseconds(BRIGHTNESS1);
    }

    digitalWrite(digit5, DIGIT_OFF);
    digitalWrite(digit6, DIGIT_ON);
    ShowNumber(aa );
    delayMicroseconds(BRIGHTNESS);
    ShowNumber(10);

    digitalWrite(digit6, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_ON);
    ShowNumber(yy);
    delayMicroseconds(BRIGHTNESS);
    ShowNumber(10);
    digitalWrite(digit6, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
  }

  //===================================================================

  void displaychar(int charshow1 , int charshow2) {
#define BRIGHTNESS 2000
#define BRIGHTNESS1  400

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
    
    digitalWrite(digit6, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_ON);
    ShowNumber(charshow2);
    delayMicroseconds(BRIGHTNESS);
    ShowNumber(10);
    
     digitalWrite(digit5, DIGIT_OFF);
     digitalWrite(digit6, DIGIT_ON);
    ShowNumber(charshow1 );
    delayMicroseconds(BRIGHTNESS);

    digitalWrite(digit6, DIGIT_OFF);
    digitalWrite(digit5, DIGIT_OFF);
    ShowNumber(10);
  }

  //====================For storing alarnm data in flash memory===========

  void ALARMSTORE(int alm_set1 , int rw ) {

    static unsigned int altim;
    static unsigned int altim1;
    int EEAddr = EEADDR;
    int EEAddr1 = EEADDR1;
    altim =  alm_set1 % 100;
    altim1 = alm_set1  / 100;

    // Serial.print("EEPROM Written");


    if (rw == 1) {

      EEPROM.update(EEAddr , altim); EEAddr += sizeof(altim);
      EEPROM.update(EEAddr1 , altim1); EEAddr1 += sizeof(altim1);

      alm_set = altim1 * 100 + altim;
      alm_set1 = alm_set;

    }

    else {}
    if (rw == 0) {
      // EEPROM.get(EEAddr , altim); EEAddr += sizeof(altim);

    }
    else {}

  } //-------------------- end of  ALRMSTORE

Credits

Ajith Kumar B

Ajith Kumar B

3 projects • 3 followers
Civil engineer.

Comments