Motion Sensitive LCD Real-Time Clock/Alarm/Timer (Updated Program)





Introduction: Motion Sensitive LCD Real-Time Clock/Alarm/Timer (Updated Program)

I needed a clock for my home office (where I spend weekend mornings building robots and such) and I wanted it to fit in with the decor of my electronics work bench. I decided to build one with all the "guts" exposed. The specs were:

- Real Time Clock
- LCD Display Date and Time
- Include Minute Timer (for timing things while building projects)
- Include Alarm (to remind me I've been in here too long)
- Motion Sensitive (save power by turning off LCD when I'm not in the room)
- Look Cool on my work bench!

Step 1: Materials

- Arduino Uno (from Radio Shack)
- LCD Keypad Shield for Arduino (from DFRobot)
- DS1307 Real Time Clock (from Adafruit)
- Enclosure Box (from Radio Shack)
- Piezo Buzzer (from Radio Shack)
- PIR (Passive Infra-Red) Motion Sensor (from Parallax)
- Female/Female Jumper Wires (from Adafruit)
- 2.1mm DC barrel jack (from Adafruit)
- 9V battery clip with 5.5mm/2.1mm plug (from Adafruit)
- 9V wall wart

Step 2: Assemble RTC Board

The Adafruit DS1307 Real Time Clock breakout board kit is just that; a kit. All components are included and it's very simple to assemble with a little bit of light soldering. Adafruit provides complete instructions at The kit even includes a 3 volt lithium coin cell that will keep the clock running for years.

NOTE: Photos are from Adafruit's instruction document.

Step 3: Power Connector

I wanted to be able to remove the Arduino board easily for future tinkering, so I cut the battery connector off of the 2.1mm plug and soldered the wires to the barrel jack. Then, I drilled a hole in the enclosure box and super glued the jack to the box. Now I can easily connect and disconnect the Arduino as needed.

The 9v wall wart simply plugs into the back of the box.

NOTE: If you look closely at the photo, you'll see that I drilled an "extra" hole too close to the screw post and then covered it with black electrical tape when I figured out the jack wouldn't fit there.

Step 4: Attach Cables to All Components

Adafruit sells these really cool Female/Female Jumper Wires in a ribbon cable. I use them for everything I build these days. You just tear off the number of wires you need and they make a nice little pluggable cable for each device.

I attached cables to the RTC, the PIR sensor, and the Piezo buzzer so I can easily connect them to the LCD shield.

Step 5: Connect Everything to the LCD Shield

The LCD shield has 5 rows of pins corresponding to analog pins 1-5 of the Arduio board. There's a row for 5v, GND, and signal, so I used these pins to connect the other end of my component cables. I use the analog pins to interface with the RTC, sensor, and buzzer and of course the sensor and RTC need power and ground connections.

Step 6: Mount Everything in the Enclosure Box

The next step is to attach the Arduino board to the enclosure. I had to lay the cables into the box first and hang the LCD shield to the right while I attached it. Otherwise I would have had to thread the cables through after the fact. 

I attached the Arduino to the bottom right screw post on the box. It fit securely with just one screw because the board is exactly the same height as the inside of the box and it rests against the plastic rails inside the box (top and bottom).

Next, I plugged the LCD shield on top of the Arduino and routed the wires around the right side of the boards.

The RTC board fit nicely in the bottom left corner of the box. I attached it with one screw as well. After attaching it, I was able to plug the power plug into the 2.1mm jack of the Arduino.

I had to mount the PIR sensor so that it could be easily removed since it blocks the Arduino's USB port. So I attached it using a strong piece of wire and looped it around screws on the PIR sensor board and the upper left corner of the LCD shield.

Step 7: Programming the Clock (Updated 7/30/2012)

As I mentioned in the intro, I wanted it to display the date and time, but also have functions for a minute timer and alarm.

The LCD shield has 5 programmable buttons on the front, so I used them to set the different features of the clock. The piezo buzzer creates a beep on each button push and a series of beeps for other functions like the alarm.

Programming the Arduino Sketch

I started with Adafruit's Arduino sketch for the RTC and their RTClib, which is actually a fork of Jeelab's fantastic RTC library. You can find the code at

Then I added some code from DFRobot for the LCD shield (including the button controls) available at

And, finally, I added my own code to complete the project. The completed sketch is available on github at

The photos show the LCD as I set the different options.

UPDATED: 7/30/2012
- Fixed noon showing as 12am
- Fixed displaying PMM when switching to PM
- Added alarm set indicator (asterisk after time)
- Validate alarm hours > 0 and < 13
- Fixed allow alarm minutes to be 0 (i.e. 8:00)
- Added setDateTime feature
- Added clearAlarm feature

UPDATED: 8/1/2012 Download Updated Source Code
- Fixed default day and hour settings on set date/time
- Added maxCount to getTimerMinutes
- Fixed alarm set PM

Step 8: Function Buttons

The LCD Shield contains six labeled buttons (see the photo). I programmed the first five as follows:

Button #1 (labeled SELECT) is my Menu button. This button displays a scrolling list of available functions (Minute Timer, Set Alarm)

Button #2 (labeled LEFT) is my Select button. Click to select the displayed menu option. NOTE: Also used to increment by 10s when entering hours, minutes, etc.

Button #3 & 4 (labeled UP& DOWN) are my Increment & Decrement buttons. Click these to increment or decrement hours and minutes while setting the timer or alarm. Also used to toggle AM and PM.

Button #5 (labeled RIGHT) is my GO button. Click to accept the value entered (such as minutes and hours).

Button #6 (labeled RST) is the Reset button which reboots the Arduino

2 People Made This Project!


  • Epilog Challenge 9

    Epilog Challenge 9
  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Science of Cooking

    Science of Cooking

We have a be nice policy.
Please be positive and constructive.




How to Make this without a LCD keypad shield....?

hey sir how if my lcd no have keypad ?
but i have push button can give me tutor ? thankss ^_^

Thanks Man, you did a great job


I just wanted to tell you how much I enjoyed your project. I appreciate the amount of time that went into the coding especially. I built a modified version to suit my tastes, and not being much good at writing code, it took me an extra day to get things straightened out. I ditched the PIR and built a voice recorder around an ISD1730 module and also added a DS18B20 temp sensor. It was fun and without all of your efforts would have been impossible on my own.


If you want to make this project work with one of the older key pad shields that do not have the pins on it like the one shown in the above project you will have to add pins as shown in photo. Then run a jumper from the ground pin to a small bread board to create a negitive rail and do the same with the +5 volt pin.
Attach jumpers like this
Your buzzer leads:
Buzzer (+) The positive lead on your buzzer connects to A1-S - Blue Dot
Buzzer (-) The negative lead from your buzzer connects to the ground rail (row) you created on the bread board with jumper from ground pin (either of the black dots with white centers)
Your motion detector leads:
PIR Motion Sensor (VCC) The positive lead connects to your 5 volt rail on your bread board
PIR Motion Sensor (GND) The negative lead connects to your negative (ground) rail on your bread board
PIR Sensor (OUT) This is the lead your motion sensor uses to send the signal to your clock and it connects to A-2 - the yellow pin
Your real time clock:
RTC (5V) Your Real Time Clock positive lead connects to the 5 volt rail on your bread board
RTC (GND) The negative lead connects to your negative (ground) rail on your bread board
RTC (SDA) connects to A4 - Where the pin in the white dot location is.
RTC (SCL) connects to A5 - Where the pin in the red dot location is.

And do not try to power this clock with a battery. You will get lots of errors in the function of the clock. Have fun, that's the point.


Hello, Can i used RTC from DF Robot? Is there a big difference if we use DF robot instead of ADAFRUIT from RTC? Thanks.

Any RTC should work, although you may have to change a little code. I would refer to DF Robot for details on their library.

Hello, I'm just starting to build this project. And thanks mikesoniat for taking the time to put this Instructable together. It's really nice work. I've been looking forward to putting it together for awhile, and the comments are very helpful as well. My LCD shield must be an older model because it doesn't have the 15 pins in the lower right hand corner. I'll have to find a datasheet for it. It's going to be displayed in a place of honor on top of my TV. I have a nice work bench where I do my soldering but it seems I do most of actual assembly on the footstool in front of my couch. Then if need be I watch how-to videos from YouTube via my Roku on my TV while I put together the project. :-) I'll let you know how it turns out. Really I think this part is the most fun! But the story about our fellow Instructabler arnefi (see below comments) is sad. I hope he made it and saw his finished project. It appears he made his last comment sometime in 2013 so I suppose he has passed on. Bless him and I hope he's making lots of solder smoke in that big workshop in the sky.


Thanks, and good luck with the build!