Introduction: Clock, LCD Display, Infrared to Set
Build a real time clock that keeps actuate time within a few minutes a year. The code and components can easily be repurposed into other projects.
This is an Arduino based digital Clock to display real time on a 16x2 LCD using a DS1307RTC module. The date and time can be set via serial interface or push button switches. La Crosse Technology 513-1211 Atomic Wall Clock with Jumbo LCD Display with Indoor Temperature. 4.3 out of 5 stars 185. 04 $109.95 $109.95.
This project requires a minimum amount of wiring and no soldering. The time keeper is a DS3231 real time clock. The time is displayed on an inexpensive 1602 LCD. Both modules use I2C communications. I2C only use 2 wires per module when connecting to an Arduino. I'm using an Arduino Nano because it fits nicely on a breadboard. The following instructions will work with an Arduino Uno as it has the same pin numbers as the Nano for this project. The other component is the infrared receiver. It allows you to use a common remote controller such as TV remote to set the time just like you would on our smart TV. The infrared receiver only requires one wire to connect it to the Arduino.
The first step is testing the Arduino and wiring it to the breadboard. The steps following that are designed to work independently. Each step has wiring instructions and testing instructions. When I build projects, I wire and test each component to confirm they are working. This helps integrating number of components because know that each work and I can focus on the integration requirements.
This Instructable requires that you have the Arduino IDE installed. You are also required to have the basic skills to download an Arduino sketch program from the links in this project, create a directory for the program (directory name same as the program name). The next steps are to load, view and edit the program in the IDE. Then, upload the program through a USB cable to your Arduino board.
- Nano V3 ATmega328P CH340G Micro controller board for Arduino. As an alternative, you can use an Uno.
- DS3231 real time clock and a CR2032 battery.
- 1602 LCD with an I2C module
- Infrared receiver and remote control. I used an IR Wireless Remote Control Module Kits which came with an Infrared receiver and infrared remote control.
- Wire cables
- 5 volt wall adapter
I bought the parts on eBay, mostly from Hong Kong or China distributors. US distributors sometime have the same or similar parts for reasonable prices and faster delivery. The China parts take from 3 to 6 weeks to be delivered. The distributors I've used have all been reliable.
Approximate costs: Nano $3, DS3231 $1, LCD $3, Infrared kit $1, breadboard $2, package of 40 wire cables $1, $1 for a 5 volt wall adapter. Total, about $11. Note, I bought the Nano and LCD with the breadboard pins already soldered in place, as I my solder skills are poor. For the clock battery, I bought a 5 pack of lithium CR2032 batteries for about $1.25. I also bought a 5 pack of DS3231s because I like time pieces. This project uses 1 breadboard. I bought a 3 breadboard package for about $7; a better deal than buying an individual board.
Step 1: Add the Arduino Nano to the Breadboard
Plug the Arduino Nano into the Breadboard. Or, if you prefer, you can use an Arduino Uno for this project; they both use the same pins for this project. Connect the Nano (or Uno) to your computer via a USB cable.
Connect power and ground from the Arduino to the breadboard's power bar. Connect the Arduino 5+ pin to the breadboard's positive bar. Connect the Arduino GRN (ground) pin to the breadboard's negative (ground) bar. This will be used by other components.
Download and run the basic Arduino test program: arduinoTest.ino. When running the program, the onboard LED light will turn on for 1 second, then turn off for 1 second. Also, messages are posted which can be viewed in the Arduino IDE Tools/Serial Monitor.
As an exercise, change the time delay on the blinking light, upload the changed program, and confirm the change.
Lcd Clock Display Module
In the above photo is a 140 piece solderless breadboard jumper wire kit box you can get for 3 to 5 dollars. They make boards neater that using long cables for short connections.
Step 2: Add the DS3231 Clock Module and Connect It to the Arduino
Plug the clock module into the breadboard. Connect the GND pin of the clock module, to the breadboard's ground bar strip. Connect the VCC pin of the clock module, to the breadboard's positive bar strip. Connect the clock module SDA (data) pin to the A4 pin of the Arduino(I2C data pin). Connect the clock module SCL (clock) pin to pin A5 of the Arduino(I2C clock pin).
Big Display Clock
In the Arduino IDE, install a DS3231 Clock Library. Select Tools/Manage Libraries. Filter your search by typing in ‘rtclib’. Select RTClib by Adafruit (for reference, the library link).
Download and run the basic test program: clockTest.ino. When running the program, clock time messages are posted which can be viewed in the Arduino IDE Tools/Serial Monitor.
As an exercise, use rtc.adjust() to set the clock's time and date, upload the changed program, and confirm the change.
Step 3: Add the 1602 LCD Display Module and Connect It to the Arduino
Plug the LCD module into the breadboard. Connect the GND pin of the clock module, to the breadboard's ground bar strip. Connect the VCC pin of the clock module, to the breadboard's positive bar strip. Connect the clock module SDA (data) pin to the A4 pin of the Arduino(I2C data pin). Connect the clock module SCL (clock) pin to pin A5 of the Arduino(I2C clock pin).
In the Arduino IDE, install a 1602 LCD Library. Select Tools/Manage Libraries. Filter your search by typing in ‘LiquidCrystal’. Select LiquidCrystal I2C by Frank de Barbander (for reference, the library link).
Download and run the basic test program: lcd1602Test.ino. When running the program, clock time messages are posted which can be viewed in the Arduino IDE Tools/Serial Monitor.
As an exercise, change the LCD display messages, upload the changed program, and confirm the change.
Step 4: Add the Infrared Receiver and Connect It to the Arduino
Plug the female to male cable wires into the infrared receiver(female ends). Connect the ground pin of the clock module, to the breadboard's ground bar strip. Connect the power pin of the clock module, to the breadboard's positive bar strip. Connect the output pin of the infrared receiver, to the Arduino A1 pin.
In the Arduino IDE, install an infrared library. Select Tools/Manage Libraries. Filter your search by typing in ‘IRremote’. Select IRremote by Shirriff (for reference, the library link).
Download and run the basic test program: infraredReceiverTest.ino. When running the program, point your remote control at the receiver and press various buttons such as the number from 0 to 9. Serial messages are output (printed) which can be viewed in the Arduino IDE Tools/Serial Monitor.
As an exercise, use a TV remote to see the values printed. You can then modify the program to use the values in the infraredSwitch() function's switch statement. For example, press the '0' key and get the value for your remote, for example, '0xE0E08877'. Then, add a case into the switch statement as in the following code snippet.
Step 5: Load the Clock Project Arduino Sketch Program and Test It
Now that all the components are added to the breadboard, wired, and tested; it's time to load the main clock program and run it. The clock program gets the time from clock module, displays the time on the LCD, and allows you to set the time using an infrared remote control.
Download and run the project's clock program: clockLcdSet.ino.
When the program starts, it will display the DS3231's time on the 1602 LCD screen. Messages are viewable in the Arduino IDE Tools/Serial Monitor.
Point your remote control at the receiver and press the right arrow button. The year will be displayed for setting. Press the right arrow button a number of times to see that you can set the year, month, day, hour, minute, and seconds. To set a time value, go to the value. Use the up and down arrows to set the display value. Then use the 'OK' key to set the clock's value. One value is set at a time.
Step 6: External Power Supply
Now that your clock is tested and working, you can unplug it from your computer and use an independent power supply. For simplicity, I use a 5 volt wall adapter, which can be bought for about a dollar, and a USB cable, another dollar. The cable connects the Arduino to the +5V wall adapter. Since the Arduino power and ground pins are connected to breadboard, that will power the other components.
Because of it's simplicity and low cost, I use this same combination to power other projects.
I hope you were successful and enjoyed building an infrared controlled LCD clock.
Be the First to Share
Lcd Display 16x2
Small Lcd Clock Display
Lcd Wall Clock
Toys & Games Contest
Big vs Small Challenge
Fix It Challenge