【Create Clock in Arduino】Step by Step Guide ▷ 2022

One of the best features of , is its versatility and ease of use, since it is a platform based on free software and hardware that supports creators and developers. Therefore, it is a great tool for create electronic projects .

Among the main jobs that it allows to carry out Arduino, meet the clocks. By default, these are ideal to start practicing and become more familiar with the assets that the platform offers.

worth knowing how to create a clock with Arduino and what uses it can be given; which, you will be able to know in this post. As well as the best kits available on the market to implement these ideas.

What do I need to create a clock with Arduino from scratch? Used materials

To build such an accessory with the help of Arduino, certain items are required depending on software and hardware. In the case of software, it is only necessary to use the (or Arduino IDE) which is the multiplatform app written in programming language .

In terms of hardware, it is recommended use a (either or any other model), as well as, an RTC module and male-female cables. If you want to create a digital clock, you must also use: a 7-segment, 4-digit display, a breadboard, a 9V battery, a pair of push buttons, and 6 220-ohm resistors (or Similar).

Learn step by step to create a clock with Arduino from scratch to use in other projects

As we noted above, it is necessary to use elements of software and hardware when building a clock with Arduino.

Therefore, during the creation process, it is worth considering the following step-by-step methods:

See also  【 Make Group Calls by WhatsApp 】 Step by Step Guide ▷ 2022

Via Software

Initially, the clock has to be made with Arduino hand in hand with the development environment of this platform. Based on a library (in this case, Time.h) that must be installed by any of the following ways: Adding Library. Zip, through the library folder or through the Library Manager. To add the Time library to the Arduino IDE, simply click on the tab “Program”select the option “Include Library” and choose time in the listing.

This will add the following code to the software:

#include #include void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: }

To execute the first functions of the clock with Arduino (hour, minutes and seconds), the code corresponds to:

#include #include void setup() { Serial.begin(9600); } void loop() { // Print the time Serial.print(“Time: “); Serial.print(hour()); Serial.print(“:”); Serial.print(minute()); Serial.print(“:”); Serial.println(second()); delay(1000); }

To set the code correctly, it is worth considering that eIn the setup() function, the serial monitor is started to display the data:

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

In the loop() function, the functions are used:

Serial.print(hour()); To return the time. Serial.print(minute()); To return the minutes. Serial.println(second()); To return the seconds. Serial.print(day()); To return the day of the month. Serial.print(month()); To return the month. Serial.println(year()); To return the year.

Subsequently, to set the correct time on the clock with Arduino, You have to use the function setTime(…) which can be called in different ways, depending on the various parameters to return one type of foundation or another; depending on the needs of the creator or user. In this case, the data is important: hour, minutes, seconds, day, month and year, as follows: setTime(hour, minutes, seconds, day, month, year);

See also  【UNLOCK iPhone 6, 6+, 6S and 6S+】Step by Step Guide ▷ 2022

Thus, the modified code would be the following, for example:

void setup() { begin(9600); // Set the time and date setTime(11, 40, 6, 14, 8, 2021); }

By Hardware

To build a clock with Arduino starting from hardware, an RTC component is required. Well, these use a crystal oscillator or the network frequency and They are used to have a real time clock that prevents the errors that the Time.h library usually throws (sometimes it loses time). In general, RTCs have an alternative power supply that is used when the main power is off and guarantees the preservation of the time and date at all times.

Within the extensive range of RTCs suitable for Arduino, the components stand out DS3231 and DS1307 which are closed circuits. Between these two solutions, the DS3231 is much more accurate than the DS1307, because it has an internal oscillator in which temperature changes do not intervene and can only present a lag of a few minutes during the year. While, the DS1307 may be 5 minutes out of phase per month, due to extreme temperatures which tend to affect its accuracy.

Likewise, the DS3231 has certain alarm functions (That is, it can work as an alarm clock too). However, both components are capable of generate a square wave of various frequencies (to serve as a clock signal) and have an EEPROM memory. Regarding the connection, this is simple because both the DS3231 and the DS1307 use the I2C bus.

In summary, depending on the Arduino model that is used, the pins that must be used are:

  • Arduino UNO, PRO MINI: SDA = A4 and SCL = A5.
  • , : SDA = 2 and SCL = 3.
  • Arduino MEGA, : SDA = 20 and SCL = 21.
  • Arduino MKR1000: SDA = 11 and SCL = 12.
See also  【 COMPUTER PORTS 】What are they? + Ranking ▷ 2022

Notably, SDA is the data signal and SCL is the clock signal.

Loading Facebook Comments ...
Loading Disqus Comments ...