Arduino Digital Clock is aimed to get the Time & Date automatically and sending them to the Arduino.
So, you can control things around you with Arduino based on the real-time and date.
If I asked you: could you please turn off the lights when it comes to 10:30?
Actually, the common answer would make a reminder on your phone to turn the lights off by 10:30.
Well, that’s ok for any normal person but not for a maker. As any maker would certainly think of automating this process by making some cool stuff which can get time automatically and take certain actions when 10:30 comes!
And his your 10-minute tutorial to learn how to get time automatically, monitoring it and make any decisions based on it.
Let’s talk about the idea behind the Arduino Digital Clock project …
We are going to get time from the smartphone automatically and wirelessly by using 1Sheeld with it’s Android/iOS App with Arduino board.
The idea behind the Arduino Digital Clock is to use the clock shield from the smartphone App and connect the App to the 1Sheeld via Bluetooth. So the App will automatically send the current date+time to the 1Sheeld board connected to the Arduino.
So we can print the current time (hours + minutes + seconds) on an LCD 16*2 and once a second passed, a minute passed or an hour passed the time on the LCD will be changed automatically … with this simple 🙂
If this is your first time to deal with 1Sheeld or you want to learn more about it, I recommend checking this quick and easy getting started tutorial.
And if you haven’t tried LCD 16*2 before, I recommend checking this quick video.
Now, after you’ve become a little bit familiar with 1Sheeld, let’s start!
Step 1: Hardware components:
– Arduino Uno.
– 1Sheeld+ board.
– LCD 16*2.
– 10K potentiometer.
– 22 * Male to male wires.
– Arduino USB cable or 9-12v battery.
– Android/iOS phone with 1Sheeld App installed on it.
Switch the 1Sheeld power to operate on 5v (Not the 3.3v):
1Sheeld have 2 modes: Uploading mode and Operating mode. You can switch between them using the switch close to the Digital pins and is called “UART SWITCH” on 1Sheeld and “SERIAL SWITCH” on 1Sheeld+.
Firstly, you slide the switch towards the “SWITCH” notation. This turns the 1Sheeld board into the Uploading mode to let you upload the Arduino code.
Secondly, after you finish uploading the code, slide the switch towards the “UART” notation (or “SERIAL” at 1Sheeld+ board) which turns the 1Sheeld board into the Operating mode to communicate with your smartphone 1Sheeld App.
Connect the Arduino via your PC using Arduino USB cable.
Step 4: Code:
I would recommend checking the Arduino Clock Shield documentation to know more about the Arduino Clock Shield functionality and how to use them.
Now, switch the 1Sheeld board to the Uploading mode, upload this code for the Arduino Digital Clock:
Arduino Digital Clock Project
This project shows an application on 1Sheeld's clock shield.
By using this project, you can monitor the current real time
by using clock shield from 1Sheeld.
You can then take certain actions based on the time you get.
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.
/* Include clock shield only */
/* Include 1Sheeld library. */
/* Include LCD library */
/* Define some variables for the time. */
// Initialize the LCD library with the numbers of the interface pins
/* Start communication. */
/* Start the clock shield. */
/* Set up the LCD's number of columns and rows */
/* Print this line to the LCD */
/* Always get the time. */
/* Set the cursor to column 0, line 1 */
/* Print the current hour */
/* Print the current minute */
/* Print the current second */
/* As once second reaches "59", it start again with "0" not "00" so, the "9" of the previous "59" will stay causing a confusion */
/* So, we clear the second line after a second has passed */
/* Move the cursor to the begining of the second line */
/* Loop to clear "print empty spaces" all the 16 places of the second line */
/* Clear "print empty spaces" to clear the previous time to print a new one */
Then, Switch the 1Sheeld board to the Operating mode then open the 1Sheeld app and connect it to the 1Sheeld board via Bluetooth.
Step 5: Run the Arduino Digital Clock:
Finally, select the Arduino clock shield from the shields list.
You will notice that the LCD is showing only zeros.
And this is normal because you have to press the Arduino reset button to make 1Sheeld send the time request again to the App.
What happened after uploading the code is that any code inside the void setup() part (where we send the time request) runs fast even faster than the time you took to switch to the operating mode. Then the Arduino lies inside the void loop() part forever.
Briefly, the Arduino sent the time request quickly. Then you switched to the operation mode where the communication between 1Sheeld and App started and missed the time request.
Hence, by resetting the Arduino after the 1Sheeld is in operating mode, it goes inside the void setup() part again. Then it sends the time request again and now the request reached the App and updates the time on the LCD!
Now, you have just finished the Arduino Digital Clock.
You can add your own extra code to check whether the time reached a certain value then take a proper decision.
These decisions may be like switching lights connected to a relay. And maybe open the fan for you to cool weather just at the time you return home 🙂
Hope you enjoyed this Arduino Digital CLock project!
If you have any question, please don’t hesitate to leave it in the comments down below.
Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …
Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …
“Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …
Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …
Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …
MQTT is one of the most commonly used protocols in IoT projects. It stands for Message Queuing Telemetry Transport. In addition, it is designed as a lightweight messaging protocol that uses publish/subscribe operations to exchange data between clients and the server. Furthermore, its small size, low power usage, minimized data packets and ease of implementation …