I have a real-time Clock module and I'm trying to make an RGB Clock out of it. There is a particular line of code that sets the time and date to the real-time clock module. I put this in the setup code but every time I reset the Arduino it runs that line of code again. Is there any way that I can make sure that once this line in of code is run it will never run again even if I reset the Arduino?
How do I make sure the Arduino only run this line of code once even after reset?
279 Views Asked by Elliot At
2
There are 2 best solutions below
0
datafiddler
On
Your RTC might have a bit saying "RTC stopped", which you might use to switch to "normal behavior". It will be set when removing power and the RTC-battery. The RTC will probably read "1-Jan-1970 00:00" then, and won't increment unless set.
However, your demo code to set the RTC is just demo code, not intended to really use as is. (See Victor's response for more details)
Related Questions in ARDUINO
- How to fix python serial monitor parsing error?
- How can I break bricks?
- Soft WDT reset on Wemos D1 Mini
- Arduino TFT module 240x320 OLED not working
- Async Web Server RP2040 returning ERR_CONNECTION_REFUSED?
- ESP32 Consequtive Interrupt WDT Timeout Exception
- Adafruit BNO08x Lib Not working with PicoRP2040 - PlatformIO
- SPI - R/W to ST95P08 EEPROM
- arduino disambungkan ke konputer nyala dan mati lagi
- How to correctly read POST REQUEST body on ESP32?
- How do I publish sensor data to EMQX broker on Ubuntu from a remote Arduino (no WiFi) interfaced with SIM800L?
- Portenta H7 Baremetal Development and a Little Guidance on Embedded System Learning Roadmap
- Wifi disconnects and connects again and again while using esp8266, max30100 and oled display
- Arduino-cli commands are not found in vscode using WSL, why is this occuring?
- Implementing Image Processing for Dimension Measurement in Arduino-based Packaging System
Related Questions in ARDUINO-C++
- Async Web Server RP2040 returning ERR_CONNECTION_REFUSED?
- Is there a way to implement std::regular_invocable as a type_trait style function in c++11/c++14?
- Using FastLED and SharpIR Libraries with Generic ESP8266 Board
- How do I modify this DC motor encoder code to work with 4 DC motors?
- Arduino C: program not behaving correctly without printing variable to serial monitor
- Sending data from mysql via php to arduino
- getting 'I2S_MODE_DAC_BUILT_IN' was not declared in this scope error when compiling for ESP32S3
- Arduino MKR Zero keyboard emulation not working
- TinyGPS++ Not Showing some data | failed checksum issue
- esp32: Doing some math in c++ results in inf
- Possible Macro Definiton Clash with Arduino Core Library
- Problem when creating arduino library with dependencies
- How to pass a variable to a function in c++
- How do I efficiently write to every 12th bit of an array of three 32-bit integers?
- RP2040-Zero (using Arduino C++) does not persist loaded program
Related Questions in REAL-TIME-CLOCK
- STM32 RTC3 Mixed Mode: Writing TR resets SSR
- RTC for Riverdi STM32 Embedded Display RVT70HSSFWCA0 not running when power is off
- How to build a reset loop in micropython
- Modifying the format of RTC values in ZPL
- STM32L0 LoRaWAN -> Whenever I set date and time to internal RTC, my system will crash
- How do I set the system clock in Rust?
- Stm8l mcu RTC calibration problem using RTC_SmoothCalibConfig()
- How to get and set RTC time(hwtime) from android native service?
- The Last Tick Animation of the Arms of the Virtual Clock
- Converting a 24-Hour clock with Images to 12-Hour clock with AM and PM with Day and Date
- STM32 RTC stops working after 10 minutes of work with battery as power source
- Managing RTC drift while in ESP32C3 deep sleep using internal oscillator?
- STM32 RTC won't start if LSE drive capability not set
- Hwclock shows wrong output with custom RTC driver
- Converting 24 hr formatted time to 12 hr format in HTML
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It is a broad question which goes beyond programming. The answer to your concrete problem is "Remove that line of code" from
setup, it will not run (I am sure you know this). However, you should provide some physical input (buttons + rudimentary menu-like interface) to set the clock on first usage. A second way of setting the time can be a serial port to which you can physically connect. This requires some code to read that serial port in yourloopmethod.In the release version of you Clock firmware I would leave just reading the time stored in EEPROM (from RTC module or an external chip), not the hard-coded value in
setup.