Panel Cookies
yt_link
insta_link
fb_link
twitter_link

Real time clock read


Real rime clock Arduino - CODE
Help me by sharing this post



Download the .zip file below. Open the Arduino (.ino) code on your Arduino IDE and upload it to the Arduino board that you use. Make sure you have the connections as in the schematic below. You could also copy and paste the code from below.

Set time example code:

Remember to install the DS3231 library:





rtc Arduino mega






// DS3231:  SDA pin   -> Arduino UNO: A4 pin / Ardunino MEGA: SDA pin
//          SCL pin   -> Arduino UNO: A5 pin / Ardunino MEGA: SCL pin

#include <DS3231.h>     //Downlaod library here: https://www.electronoobs.com/eng_arduino_ds3231.php
DS3231  rtc(SDA, SCL);

void setup()
{
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
  //rtc.setDOW(MONDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(11, 47, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(28, 8, 2018);   // Set the date to January 1st, 2014
}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
  delay (1000);
}








ADVERTISERS



PCBWAY PCB service





Curso Arduino Online nivel Intermedio