Features
- Shows date and time on serial monitor
- Shows date and time on a 32x16 LED matrix panel
- 3 display mode (Font_Normal, Font_3x5 & Font_Large)
- Very bright LED, suitable for indoor & outdoor
- Adjust settings via serial interface or push button switches
- 8 steps brightness control
- Enable/Disable Alarm
- Keeps time running after electricity failure
- Using a homemade Arduino which is very simple & low cost
Updated on 20 Aug. 2016
Design a GUI interface using AutoIT scripting language to read settings from and write settings to the LED clock.
Libraries
You need to download and install the following libraries before you can upload sketch to your Arduino.
RTC.h, DS1307RTC.h, SoftI2C.h
The RTC.h library adds timekeeping functionality to Arduino with or without external timekeeping hardware.
The DS1307RTC.h library allows you to access the DS1307 realtime clock chip via I2C.
The SoftI2C.h library implements the master side of the I2C protocol in software on any arbitrary pair of pins for DATA and CLOCK.
DMD2.h
A library for driving the 32x16 dot matrix LED display
SystemFont3x5.h
DMD2 does not include the 3x5 fixed width font in their download, you must copy it to your DMD2 fonts folder.
Freetronics DMD (Dot Matrix Display) Library
There are several ways to drive the 32x16 LED Dot Matrix Display from an Arduino, I found that Freetronic DMD and DMD2 are the most easy to use library for display text & simple shape like circles and boxes.
DMD2 added features such as brightness control which allows the Arduino to control the brightness of the display. Only four functions from the library is used in the Arduino sketch.
- dmd.begin()
- dmd.clearScreen()
- dmd.setBrightness(brightness)
- dmd.selectFont(Font)
DMD2 includes several font file types in the library font folder, there are:
- Arial_Black_16.h
- Arial14.h
- Droid_Sans_12.h
- Droid_Sans_16.h
- Droid_Sans_24.h
- SystemFont5x7.h
The 3x5 fixed width font file type is missing from their library. Finally I found a "3x5 Fixed Width Font" from the Freetronics forum which is contributed by Micah.
Note: DMD2 library is not backwards compatible with the original DMD library. It's currently a beta release.
DS1307 RTC
The DS1307 serial real-time clock (RTC) is a low- power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. DS1307 works on I2C protocol which can interfaces to most microcontrollers.
A 3 volt lithium coin cell battery is connected to the DS1307 which keeps time running after electricity failure. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply.
32x16 LED Dot Matrix Panel
The LED matrix panel is arranged in 32 rows by 16 columns (512 LEDs total) which can be used to display digits, letters and even graphs. I'm using a P10 (10mm pitch ) LED matrix panel with the size 320mm(W) x 160mm(H) x 30mm(D), it is designed for outdoor (extra bright).
The LED matrix panel is available from several sellers & design. You can use it on this project as long as the interface (16 pins IDC connector) is complied to Hub12 protocol. Figure below shows the Hub12 pinout.
ATMega328 Arduino
Initially I'm using an Arduino UNO for this project.
It is then using a homemade Arduino after the project has been completed.
Implementation
The DMD library is conflicted with the analog pin when used with DS1307RTC, please do not interface the DS1307RTC with the hardware I2C since it uses Analog 4 (SDA) & Analog 5 (SCL) as the signal pin. In order to overcome this problem, the software I2C library is used in this project which allows the DS1307RTC connect to any IO pin (D0 to D13) except the analog IO (Analog 0 to Analog 5).
Since most of the IO pin is occupied by Serial (D0, D1) and DMD (D6, D7, D8, D9, D11, D13), the available pin would be D2, D3, D4, D5, D10 & D12, therefore I use D2 & D3 as the software I2C pin for the DS1307RTC, D4 & D5 for alarm1 and alarm2 respectively.
Note: Do not use Analog pin for Alarm output, the analog pin will change to high and then goes low automatically.
The three push button is control by an anlalog pin (A0) which used to adust the clock settings. I'm using the following sketch to test the buttons in order to know the exact input value for each buttons.
Source Code
The source code and the libraries is packed in a single file which is available in GitHub, alternately you can download from my website.
Adjust Settings via Serial
Connect a USB-Serial adapter to the LED clock, you can adjust the clock settings via the serial interface from your computer.
- Open serial console from Arduino IDE, make sure selected the correct serial port.
- Set baud-rate to 9600.
- Select Both NL & CR next to baud-rate as shown in figure below.
- Send a valid command to the serial port, you should able to adjust the clock settings.
Command List
Command | Format | Remarks |
Set Mode | Mx | Where x is ranged from 0 to 2. Eg. M0 will set to Normal font |
Set Brightness | Bx | Where x is ranged from 0 to 7. E.g. B1 will set brightness to 1 |
Set Date | Dyymmdd | E.g. D160123 will set date to 23rd Jan 2016 |
Set Time | Thhmmss | T012345 will set system time to 01:23:45 |
Set Alarm | Ahhmmssx | Where x is the alarm ID. E.g. A0123450 will set the first alarm time to 01:23:45 |
Enable Alarm | Esx | Where x is the alarm ID, s is the status either 0 (ON) or 1 (OFF). E.g. E10 will enable first alarm, E00 will disable first alarm. |
Adjust Settings via Push Buttons
The LED clock built with three push buttons (SET, UP, DOWN) used to change the clock settings.
- Press SET button to bring up the menu.
- Press UP or DOWN button to scroll the menu items (1=Display Mode, 2=Set Brightness, 3=Set Date, 4=Set System Time, 5=Set Alarm Time, 6=Enable/Disable Alarm)
- Press SET button to select the desired item.
- Press UP or DOWN button to change the settings.
- Press SET button to save and activate the settings or idle 10 seconds will return to main screen without any changes.