Other Arduino Codes and Videos by Robojax

Build Seven Segment LED clock with Arduino

دروس آردوینو به فارسی

Seven Segment LED Clock with Arduino and DS3231

This code is for video instruction on how to build Seven Segment LED clock using DS3231 Real Time Clock and Arduino. Robojax Library Makes it very easy to build clock in a few lines.

Resources for this sketch


 /*
 * Seven Segment LED Clock with Arduino and DS3231
 * with Robojax Library
 * 
 * Written by Ahmad Shamshiri 
 * on July 26, 2018 at 21:29 in Ajax, Ontario, Canada

watch video instruction for this code:https://youtu.be/qB0drI56zGE
Watch video instruction for DS3231: https://youtu.be/7hBtXdoaAOY
Get this code and other Arduono codes from Robojax.com
If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon http://robojax.com/L/?id=63
or make donation using PayPal http://robojax.com/L/?id=64

 * 
  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#include <Wire.h>
#include <DS3231.h>
DS3231 clock;
RTCDateTime dt;

#include <Robojax_SevenSegmentClock.h>
const int digits[]={9,10,11,12};// define digits pins
const int displayPins[] = {2,3,4,5,6,7,8}; // define segment pins
const int colonPin = 13;// colon pin
const int type =1;//1 common Anode, 2 for commond cathode
Robojax_SevenSegmentClock clk(displayPins,digits,colonPin,type);

int blinkTime=0;// do not change. Used internally
int blinkStatus=0;// do not change. Used internally

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

  // Initialize DS3231
  Serial.println("Initialize DS3231");
  clock.begin();//for DS3231 
  
  clk.begin();//for Robojax_SevenSegmentClock
  Serial.println("Robojax Seven Segment Display Clock");
  Serial.println("V 1.0 July 28, 2019"); 
  
  // Robojax Seven Segment Clock for Arduino
  // uncomment the line below only ONCE to updat the time. Then comment it back
  //clock.setDateTime(__DATE__, __TIME__);
}// setup ends here


void loop() {
  // Robojax Seven Segment LED Clock with Arduino
   dt = clock.getDateTime();
//  Serial.print(dt.hour);   Serial.print(":");
//  Serial.print(dt.minute); Serial.print(":");
//  Serial.print(dt.second); Serial.println("");   
  clk.displayTime(dt.hour,dt.minute);
  

  delay(1);

}// loop ends here
   

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal