■ BY JOE PARDUE
SMILEY’S WORKSHOP #56
C PROGRAMMING - HARDWARE - PROJECTS
ARDUINO PROTO SHIELD
ast month, we
looked in detail
at the Arduino alarm
clock software on
the PC side. Then,
we looked at how
date and time
■ FIGURE 1. Proto shield alarm clock on breadboard and PCB.
data are handled
THE ALARM DATA
on PCs and
Finally, we began
looking at the
Arduino side of the
As mentioned, last month we looked at how the dates and times are stored on
the PC and began to look at how they are stored on microcontrollers. Since we are
using the RTClib library for the DS1307, we will use some of that library's
conventions for storing dates and times. As we saw back in Workshop 48, the
DS1307 RTC (real time clock) keeps the dates and time in 10 bytes of binary coded
decimal numbers. The RTClib provides a way to convert that into Unix time, which is
a 32-bit number. So, we can store it in four bytes.
We also have several other parameters associated with each alarm including the
type of alarm, if the alarm is set, and if the alarm has tripped. We store these latter
three pieces of information in three variables, each being one byte.
So, the total data for each alarm is seven bytes, which is shown for alarm 1
month, we will dig
deeper into the
uint8_t alarm1_dt1; // first 8-bits of the 32-bit unix datetime
uint8_t alarm1_dt2; // second 8-bits of the 32-bit unix datetime
uint8_t alarm1_dt3; // third 8-bits of the 32-bit unix datetime
uint8_t alarm1_dt4; // fourth 8-bits of the 32-bit unix datetime
uint8_t alarm1_type; // the type of alarm
uint8_t alarm1_is_set; // is the alarm set?
uint8_t alarm1_is_tripped; // has the alarm tripped?