Led Matrix Auto Brighteness Alarm Clock




Introduction: Led Matrix Auto Brighteness Alarm Clock

16 days and eight hours ago I started this great project, a project filled with troubles and transistors. But through it all I learned things I didn't know before... Just kidding I had some sort of idea of what to do before I started. Before you start any adventure in electronics always do your research. There is two parts to this, building an Awesome Orange LED matrix and then how to run it with 74hc595 ICs and an Arduino. My original purpose for making this was I wanted to build a LED display and learn how to use it. Then because most people want to know the reason for building something I decided to turn it into a alarm clock. And if your not kudos to you! The code is all original so use it as you please, cause please is a nice word.

What this clock does.Well if you need further information it is a clock... that tells the time.... not verbally but... Ugh you get what I mean. Also it has two set able Alarms and automatically adjusts to the current brightness of the room.


  1. Supply's
  2. LED arrays, multiplexing how it works
  3. Building the LED Matrix
  4. Building the circuit
  5. Uploading the program
  6. Troubleshooting
  7. End


Yes there are some skills you'll need, here is the list.

  1. How to program an Arduino.
  2. How to solder
  3. How to follow diagrams to the wire. See what I did there? Clever, right?
  4. Not getting bummed out and quitting when somethings goes wrong.

All these are easy to do but you might want a little experience in each one before trying this, especially the last one. This is very important. And remember "If you do not fricassee fry fry a hen." I mean "If you do not first succeed try try again." I am always getting those two mixed up, mostly because I like fried chicken.

Step 1: Supply's

Here is all the parts you need.

1x Computer to Program Arduino.

1x Arduino. (I am using the Uno)

80x 5mm LEDs.

1x Real Time Clock (RTC) module.

1x Piezo Buzzer that is loud enough to wake you.

1x Photo Resister. (Light Dependent Resister)

16x 330 ohm Resisters.

5x 1k ohm Resisters.

3x 10k ohm Resisters.

5x NPN Transistors.

2x 74hc595 Shift Registers.

2x Buttons.

1x 10k Potentiometer

1x Bunch of Jumper wires, a big bunch.

1x 830 pin Breadboard.

1x 400 pin Breadboard.

1x 5v power supply. (My Uno provides enough power)

2x Colors of 20 Gauge Wire.

1x wood Board that your will fit on.

1x Pencil.

1x Ruler.

1x Small needle nose pliers.

1x Wire Cutters.

1x Soldering Iron.

1x Rosin Core Solder.

1x Carpenters Square. (This isn't required but highly recommended)

Of course we first make our circuit on a breadboard. I am planning to use some perfboard and a bare bones Arduino to make this more permanent. Which would just require a piece of perfboard and all the parts to make a bare bones Arduino. You'll also want a frame eventually so start thinking about what your making it out off, mine is going to be 3/8" plywood glued together.

Step 2: LED Arrays, Multiplexing, How It Works

When you are using a LED display, you could either have an Arduino pin controlling each LED, which would be really inefficient, or do a thing called multiplexing or demulitplexing depending on who you ask, I'll call it multiplexing because its the name its most commonly known by. The idea behind this is quite simple, you have a number of rows which vertical lines of anodes are connected, and a number of columns where horizontal lines of outputs are connected. What we do is we turn on one column, then turn on what LEDs we want on the rows. after which we turn off the column and switch to the next. By changing the LEDs that are on or off and by going trough the columns very quickly it appears that all LEDs we want are on. This is all shown in the animated picture above. The Black lines are columns and turn yellow when active. The red lines are rows and turn green when active. Lastly the LEDs are orange and turn purple when lit. Now this all works because of Persistence of vision, which is an optical illusion where multiple pictures are played fast so that it looks like it is one fluid picture. Essentially we are playing a image every time we go trough a column which our eyes perceive as one image. Like an old motion picture. I really hope you enjoy this Instructable. Now we go to the technical mumbo jumbo.

Step 3: Building the LED Matrix

Let's start by learning how to build the matrix holder, this is going to hold all the LEDs in place while you solder them. Your going to need a piece of wood, drill, drill bits, pencil, and a ruler. The drill bit needs to create a slot that the LEDs can fit into, but not slip passed the raised edge at the end of the bulb's body.

At a right angle to the wood make 16 marks that are 3/8" apart, these are the rows.

From the rows at 90 degrees, make 5 marks at 3/8" which will be the columns.

Use the square to extend each mark to make a square grid. It should be 6 inches long and a 1 7/8 inches wide.

Use a small drill bit to start each hole, this will make it more precise.

Now make a larger hole with the correct sized bit.

This is one of the most important things you will do and will seriously affect the look of your matrix. Don't rush through this, just take your time and make it the best you can. I would recommend using a drill press so its more precise. For my part I was a bit lazy and made a 4x5 hole layout in a board thinking that I would make four modules then solder them together. The downside is that the small mistakes are made in each hole showed up four times, in a pattern, perhaps not my finest moment. :)

Now let's make the actual array, get the Soldering Iron, LEDs, solder, pliers, and the holder you just made.

Start by testing each LED you'll use, this is a long and boring process but will be worth it when you know that all the LEDs in your matrix worked in the beginning. In the pictures you can see I used two male to female wires, with one being connected to ground and the other connected to a 330 ohm resister that is connected to 5V. You'll need 80 working LEDs, so plan on doing this for a while. Isn't electronics fun and filled with boring, repetitive jobs :) I knew you'd be excited...

Plug in your Soldering Iron so it can heat up. Its time to get to the fun part.

Take your LED and with the anode away from you, use pliers to grab the cathode below the pinch point and bend it 90 degrees to the right.

Then grab the anode right above the pinched point in it and bend the anode 90 degrees away from the cathode. There are pictures of this at the TOP.

Put the LEDs into the holder in the column line starting at the bottom. Use locking tweezers to hold the leads together, MAKE SURE your connecting anodes to anodes and cathodes to cathodes making all the right rows and columns. Now put the Soldering Iron on where the two of the leads meet for one to two seconds. Then touch the solder to where the Iron and lead are touching and make a small solder joint. Now remove the Soldering Iron. Make sure to clean the Iron with a wet sponge or paper towel often.

WARNING: Do not hold your soldering iron there forever, once the solder is flowing on the lead wait a second then remove it immediately or risk burning your 6 cent LED!

Yay, one done, only 159 more to go!! :)

Once you solder together four LEDs you can test it.

Take your Arduino and connect the column to ground. Now connect one of the LED's resisters to 5V, then the other end to a wire that you can move around.

Now power up the Arduino and take the wire and touch each vertical row. The LED in the row you touch should light up.

If that worked, keep going until your done, if not then check to make sure everything is connected correctly. If it still doesn't work then you'll have to unsolder the dead LED and put a new one in.

In the end there should be pins sticking out of the matrix on the bottom and the right, when the LEDs are facing towards you. Now insert the row pins into a 60 pin long breadboard or solder wires to them. Solder wires to the 5 column leads.

You can see in the last picture what it looked like when I connected two of my small matrixs to form a bigger one. This took me a total of 3 hours, so have patience and you shouldn't have any problems. Once your done go take a break and maybe get a drink or eat something :Y Or both. I love food..... And drinks.... And drinking food...... and fooding drinks..? Did I mean that? The world may never know.

Step 4: Building the Circuit.

Here is the wiring diagram I made on Autodesk Circuits. All the LEDs should already be soldered together so you only need to connect the wires to the edges of the LED matrix. Please read the text version below before you start to make sure you completely understand what to do, plus there is how to connect the RTC to the Arduino.

Here is a text version of what the connections above are. I'll be using the breadboards grid, so please pay close attention to the instructions.

400 pin breadboard (breadboard 1)


Positive rail to 5v

Negative rail to Ground.

Shift Registers

The first thing to do is connect the shift register (SR) over the middle line with pin 1 in 1E on the breadboard, with the notch in the IC towards the top.

Now connect SR2 right below it facing the same way.

Connect pins 16 and 10 of both SR's into the 5v rail.

Connect pin 14 on SR1 to pin 2 on the Arduino.

Connect pin 13 on SR1 and SR2 to Arduino Pin 5.

Connect pin 12 on SR1 and SR2 to Arduino Pin 3.

Connect pin 11 on SR1 and SR2 to Arduino Pin 4.

Connect pin 9 on SR1 to SR2's pin 14.

Connect pin 8 on both SR's to Gnd.


Put in a NPN transistor with its flat side facing the left in row C pins 28, 29, 30.

Put in a Transistor, Flat side to the Left in row C pins 25, 26, 27.

Put a Transistor in row C pins 22, 23, 24.

Put a Transistor in row C pins 19, 20, 21.

Now one last Transistor in row C pins 16, 17, 18. you'll notice that its now sharing ground with SR2.

Connect a 1k ohm resister from the middle pin of each transistor into the Row on the other side.

Photo Resistor

Connect on leg into pin G19 and one into G17.

Connect a wire from G17 to Arduino pin A0

Connect a 10k ohm resistor from J17 to 5v.

Connect J19 to Ground.

830 pin Breadboard (breadboard 2)

Led Array

Row leads into the breadboard.


Connect each resistor to each row then over the middle to the other side of the board.

Connecting Breadboard 1 and 2

Now, from the left, connect a wire from Led1's resister to G2 on breadboard 1.

Led2's resistor goes to A1 on breadboard 1.

Led3's resister goes to A2 on breadboard 1.

Led4's resistor goes to A3 on breadboard 1.

Led5's resistor goes to A4 on breadboard 1.

Led6's resistor goes to A5 on breadboard 1.

Led7's resistor goes to A6 on breadboard 1.

Led8's resistor goes to A7 on breadboard 1.

Led9's resistor goes to G10.

Led10's resistor goes to A9.

Led11's resistor goes to A10.

Led12's resistor goes to A11.

Led13's resistor goes to A12.

Led14's resistor goes to A13.

Led15's resistor goes to A14.

Led16's resistor goes to A15.

Connect column 1, on the top, to A30 on breadboard 1.

Connect column 2 to A27 on breadboard 1.

Column 3 to A24.

Column 4 to A21.

Column 5 to A18.


Insert the button so that each one of the four pins goes into one of these points. E60, E62, F60, F62.

Connect the 10k resister to the 5v and J60.

Connect J60 and Ground.

Connect I60 to Pin 12 on the Arduino.


Its going to be a squeeze but if you bunch the resisters for the LEDs together you should be able to fit this on the breadboard.

Connect a 10k resister between one side of the button and 5v.

Connect a wire from that spot to the A1 pin on the Arduino.

Connect the other side of the button to ground.


There is three pins in Row.

Connect one of the side ones to 5v

Connect the middle one to A2 on the Arduino.

Connect the other side to Ground.


You can squeeze this on somewhere.

Connect the negative lead to ground and the positive lead to Pin 6 on the Arduino.


Connect the RTC's Vcc to 5v and Ground to Ground.

Connect SDA to A4.

Connect SCL to A5.

Now explaining the circuit above. My Arduino only has 23 digital I/O pins and we need 16 for the rows, 5 for the columns, 1 for the photo resister, 1 for the button, and 1 for the Piezo, and 1 to adjust the brightness, which equals 25 pins. So I used some shift registers that are daisy chained which allows me to use 3 Arduino pins to control 16 LEDs. Even so I still didn't have much room left for anything else.

I used 123d circuits because I found it rather helpful for showing the circuit. The only problems I had was there is no Real Time Clock or LED matrix, the transistors appear backwards, and it wouldn't use the shift registers correctly.

Step 5: Uploading the Program

You'll need to download and install the RTClib Time library that is used by Adafruit in this. You can download it from there site or directly from here. All you have to do is extract the folder and copy it into your Documents\Arduino\library. If you have Windows and it is not the installed version there will be a library folder in the Arduino file folder. Now simply upload the sketch and watch as your LED display lights up. Now all we have to do is calibrations.


Use the 1307 RTC example in the real time clock library to set the time on your RTC, this shouldn't have to be done again until the battery dies. You just have to uncomment the line that says rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); in the void setup and upload the code.

Use the Analog_Reader sketch below to show the value of your photo resister in both high and low light, record these values.

Now go back over to the Led_Clock sketch.

Make the Int brightlow equal to the low reading of your photo resister.

Make Int brighthigh equal to the high reading of your photo resister.

Adjust Int brightadjust to change the overall brightness.

Use String alarm1 to set when alarm 1 will go off. Now while it displays 12 hours it runs on a 24 hour clock, so if you want it to go off at 8 at night it has to be set to 2000. If you want it at 8:30 in the morning then put in 0830. you get the idea.

Set String alarm2 to set alarm 2.

These are the Alarms that the Arduino will revert to when the power goes out.

Once this is done you should be good.

Step 6: Trouble Shooting

LEDs won't light at all.

Most likely a wire isn't where its supposed to be, double check all the connections.

If its just a few then they might have gotten burned out when we where soldering, try replacing it.

LEDs are on but are dim.

The power supply might not be able to handle the current, though this is unlikely.

Make sure your transistors are the right way. Interesting fact, NPN transistors can be used in reverse but don't work that well, found this out the hard way. :)

Display is displaying weird random lights

Make sure the Data, Clock, and Latch pins are all connected properly.

If that didn't work try uploading to the Arduino again, it may not have gone as smooth as its supposed to the first time.

Then of course there is the possibility that some components are bad.

If this doesn't fix your problem you can ask in the comments or PM me here on Instructables. Please include a picture and a description of the problem you are having.

Step 7: End (Creative, I Know)

Well now that you got this extremely awesome led clock you might be wondering how to use it. First you can turn the alarm on by pressing button1, also the one connected to Arduino pin 12. While a alarm is active you can press and hold button2 to set the time. At the first beep it allows you to set the hour with the potentiometer, then with another press you can set the minute the same way.

There are a couple things that are still in development so I'll update this as it gets done. The only thing left is to build a enclosure and move it all off the breadboard and my development Arduino. And that is it guys. If you liked this Instructable please consider voting and subscribing.

Please leave a comment below on anything that is wrong or any ways I can improve.

Here is going to be ideas for addons, I'll add them in as you guys submit them. I'll add the first one.

  1. Motions sensor so the clock is only on when there's someone in the room.

Thanks for everything and keep building.

Circuits Contest 2016

Participated in the
Circuits Contest 2016

LED Contest

Participated in the
LED Contest

Be the First to Share


    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest



    5 years ago

    Hello supernoodle2014,

    I am building a version of your circuit for my final physics project in cegep. In my case, I have disposed of the photo resistor, of the piezo buzzer, of the buttons, of the potentiometer and of the alarm functions. Basically, I have only kept the circuitry for just the LED matrix (with the shift registers), for the Arduino Uno and for the RTC (which, in my case, is a DS3231 Precision from Adafruit). I have tried following your instructions to make the LED matrix show the time. First, I uploaded the RTC DS1307 example with the uncommented line. Then, I uploaded your own program. However, the LED matrix does not change and only constantly displays 15:31. I have tried deleting the alarm, buzzer, potentiometer, photo resistor and brightness functions in your code to only have the programming for the matrix but, in that case, the matrix doesn't show anything or simply shows a few random lines of lit LEDs. I've attached pictures of the modified code at the bottom. When I upload it, nothing shows up on the LED matrix. Additionally, I have tried uploading the example for the DS3231, but either nothing happens or the programmer doesn't respond. I would love to hear feedback from you.

    Thank you for your time,

    Zachary Tremblay

    Screen Shot 2017-11-30 at 11.19.39 AM.pngScreen Shot 2017-11-30 at 11.19.48 AM.pngScreen Shot 2017-11-30 at 11.20.07 AM.pngScreen Shot 2017-11-30 at 11.20.10 AM.pngIMG_0959.JPGIMG_0958.JPG

    Reply 5 years ago

    I added a bare bones version of the code which does appear to be working. Which makes it only a clock, not a Swiss army clock. Try it out and if you have any problems just let me know.


    Reply 5 years ago

    Thank you so much for your help! I uploaded your bare bone code, but unfortunately, now the LED matrix only displays 15:21. My hypothesis is that the DS3231 Precision RTC I'm using doesn't work, as I've tried uploading the example from the RTClib but I get no feedback. Additionally, when I move it on my breadboard, the whole LED display flickers and changes. It might be defective. Thoughts?


    Reply 5 years ago

    I would try to find a different library that uses the ds3231 rtc and try to see if you can get it working. Might just be the RTClib library has a bug. I was wondering, have you set the time on the RTC yet? Could be chip doesn't start ticking until its been set. You can also try resetting the RTC, this is done by removing both power and the battery backup for 3 seconds.


    Reply 5 years ago

    Thank you so much for your suggestion! It worked! The only thing now is the LEDs on the second and fourth column blink on and off unpredictably. I have tried checking the connections, but they all seem okay. Could it be the program?


    6 years ago

    hello i need deskboard .jpg/.png please