7/23/2023 0 Comments Arduino real time clock![]() This is done in the same procedure called display_time() as below: output = day_one << 4 | sec_one Then the output is combined together before being pushed out to the LED matrix. We need to separate the one digit and the ten digit of the day, month, year, hour, minute and second by using the division and the mod to get the remainder. The following code is the key to displaying the correct binary output: int day_one = _day % 10 As long as you had the button cell battery in the RTC clock, it will keep maintaining the clock, and you don’t have to re-initialise it every time. The above initialisation is to make sure that the DS3231 is sync with the current date and time the first time it is being executed. Then to initialise the clock for the first time, add the following code in the setup section of the code. To initialise the RTC module we need to include the following library. Once this is done, we can start to load the code from the Arduino interface. If you would like to know more details please visit the linked page, you can also asked me if you have any questions related to the connection. The detail explanation of the other part of the circuit can be found in my previous instructables post related to 8×8 Matrix Letter game. Once this is done we then connect the VCC line to 5V and the ground to Arduino GND. To do this we are connecting the SCL line from the DS3231 module to SCL line of Arduino and connecting the SDA line from the DS3231 to SDA line of Arduino. Leveraging the same circuit to connect the LED matrix to Arduino, we only need to at the RTC (Real Time Clock) DS3231 to the Arduino. However the hour will only count up to 24 and both the minute and seconds will only count up to 59. Each digit is being displayed using four LED, acting like BCD (Binary Coded Decimal) code, which is able to count up to 10. The Least significant bit is at the bottom and the Most significant bit is at the top. We also allow a space of empty column in between hour and minute and between minute and second. ![]() The hour is being displayed at the bottom row in the format of HHMMSS. The LED matrix consist of 8×8 LED, so we design the top row to be YYMMDD with a space of empty column between the Year and Month and between Month and Date. Here are the list of material that you will need: I always wanted to build an Binary clock, and since I had the LED matrix ready, and I found a concept done by other people in their project, I had an idea to re-use my LED matrix and turn it into a binary clock. This post is build on top of the LED matrix in the earlier post.
0 Comments
Leave a Reply. |