LED Matrix Hourglass - (Simple)

by hausofpayne17 in Circuits > Arduino

91 Views, 1 Favorites, 0 Comments

LED Matrix Hourglass - (Simple)

"Simple" LED Hourglass
IMG_7762.jpg

Ask yourself this question:

"What the heck do I do with the LED Matrix that came with my Arduino Starter Kit?"

An LED Matrix Hourglass is my answer; a modern take on a tool for measuring time.

Do you bake? Play Charades? Play Pictionary, Boggle or Minute to Win It? Here's a modern, FUN take on the time-tested sand hourglass design.

This was a design exercise to make a working hourglass with some SIMPLE animation. It also was to be ADJUSTABLE in minutes from 1 to 15 using a small potentiometer.

This project was another opportunity for me to develop my 3D design and printing skills.

Most importantly, it was to run on an ATTiny85 so I could keep the size small and the power consumption lower than with an Arduino.

The biggest challenge of this project was getting reasonably accurate time from the ATTiny85 at 1MHz. As it does not have an internal crystal, I was working with the RC oscillator. As such, its accuracy varies with voltage. As the voltage drops, the timer runs a few seconds longer. I got the accuracy for each minute value to within 0.6% of an equivalent phone countdown timer. That's much better than the 10% on the datasheet. See my Instructable: Accurate Timing for ATTiny85 Internal Oscillator for more information on how I managed the timing.

I developed the project on an Arduino Nano running at 5 Volts. The final ATTiny85 version runs on 4.5 Volts. The voltage difference means I had to adjust the sketch for the lower voltage. This will be discussed further when we get to the sketch section.

The circuit consumes approximately 30mA. I conservatively estimate this hourglass will operate for between 15 and 25 hours with good accuracy before the times get to run longer due to voltage decline.

Let's get building!

Supplies

2 - LED 8x8 Matrix, 32mm size with MAX 7219 interface

1 - ATTiny85 Microcontroller with programmer

1 - 8 pin socket. I prefer not to hard-solder my chips to the board so I can remove-reprogram them. It also reduces the chance I'll cook them if I were to solder them directly to the board. Omit this part if you like to attach your chips directly to your boards.

1 - 10mm piezo buzzer

1 - micro on/off switch (4mm x10mm to fit base if desired)

2 - 6mm x 6mm momentary contact switch. I used ones with 2 pins. If you have 4 pin types, they'll work fine.

1 - 10mm x 10mm 10K potentiometer

1 - 200 Ohm resistor (omit if you want the buzzer louder)

1 - 3xAAA battery holder

1 - 10K resistor

1 - IN4007 diode or similar

Small wires and small piece of prototype board for soldering - 9 holes x 8 holes (or 6x6 if you want thinner 'recessed' socket (see circuit photos).

Very thin gauge stranded wire, solder and soldering iron.

3D filament for the enclosure.

Some strong 2 sided tape to affix the battery holder to the base. I use the clear "Alien" tape as it holds really well and is not thick like foam tape.

2 - #4 x 3/8th" screws and epoxy to attach the display to the base. (any small screws with at least 2mm shaft diameter are fine.

The Arduino Sketch

NOTE: This sketch is designed to run at 1 Megahertz. So MAKE SURE you Burn your Bootloader with the chip settings to 1 MHz Internal Clock. Otherwise it may run really quickly at 8MHz. (took me a few tries to figure that out).

Set up your ATTiny85 programmer and upload the provided sketch. There are many comments to help you understand what's going on with the timing adjustments.

Some specific variables to be aware of:

secAdj: This is the number of milliseconds adjusting for the 4.5 Volt operating voltage. I found there was a 1.5 second longer time on the circuit than when running at 5 volts. You may need to adjust to your satisfaction in testing.

ofst[ ]: This array contains values of milliseconds for each of the minute values from 1 to 15. You may need to adjust these values in your own testing. In my testing I got to within 0.6% of the actual time values as measured on my iPhone.

Load the sketch on to your ATTiny85 and test to your satisfaction.

The GPIO1 button is Start/Stop. If you press it while the timer is running, it will pause the timer until it's pressed again.

When in operation, the potentiometer lets you select from 1 to 15 minutes of countdown time, displaying the corresponding number of dots on the bottom display. If you leave the bottom display with NO dots showing, you'll get a fast-demo mode where you see the 'grains' cascading quickly.

For times from 1 to 15 minutes, the falling of the 'grains' is scaled to account for the desired countdown time. Longer times mean longer periods between dropping grains.

Building the Circuit / Design Considerations

Hourglass Circuit Diagram.jpg
8x8MatrixDisplayOrientation7-7atBottomV2.png
Display Wiring Detail.png
Circuit Board View 1.png
Circuit Board View 2.png
CircuitBoardDetail.png
Internal Detail.png
Buzzer Detail.png
Under Base Detail 1.png
IMG_7761.jpg

Gather your parts. It is suggested you lay the circuit out on a breadboard first to get it working to your satisfaction.

Apologies for my circuit diagram. Learning KiCad is on my list. The intention of the diode on the buzzer is to prevent any transient voltage from getting to the pin from the buzzer pathway as a 'button press' when the pinMode is INPUT. It may not be necessary. I was being conservative. It works fine so far.

In order to try to organize the wiring in the tight space, my circuit has the displays oriented with Row 7, Column 7 at the BOTTOM for each matrix. The sketch is written to account for this orientation of the matrices.

To orient the matrices (7,7) at the bottom, place your display LEDs DOWN on the table and with the '1088AS' text on the BOTTOM RIGHT in the diamond orientation, (7,7) will be at the bottom) and the IN-side connection of the display will be on the BOTTOM LEFT of the diamond orientation.

It's recommened you solder the two displays together as shown in the second picture, then solder short jumper wires to the lower left side of the bottom display. Then you can test the display on a breadboard before returning to build the whole circuit on prototype board.

One design challenge of using the ATTiny85 was that I was short one pin for the buzzer. I could have used Pin 1 (RST) if I used a separate chip programmer to change fuses. I didn't have a second appropriate programmer.

My solution uses Pin 6 (GPIO1) for both the Start/Stop button AND the buzzer. When the hourglass is counting down, the pin is an INPUT pin. Every time it's pressed during countdown, the sketch switches GPIO1 to an OUTPUT mode and plays a short beep through the buzzer.Then it switches back to INPUT mode so the button works.

When the countdown expires, the sketch switches the GPIO1's mode back to OUTPUT, plays the ending tones and then switches back to INPUT so the button is ready for the next countdown.

The diode manages the direction of current flow based on the mode of the pin, button versus buzzer.

I wired the RST pin through a pushbutton to GND so that you may reset the whole hourglass as needed. it's preferable to switching it OFF/ON.

To minimize the height of the circuit and ATTiny85, the 8 pin socket was recessed into the prototype board rather than through-hole mounted. This saves about 2mm of thickness.This takes some careful cutting with the Dremel Tool. Since the prototype board is very thin and brittle, if you're going to do this, it's recommended you cut out the recess for the socket, SOLDER IN THE SOCKET and then cut the rest of the board to size. The soldered socket will give strength to the rest of the board as you do the rest of the cuts. It's perfectly fine to through-hole mount the socket if you prefer.

Wire up the circuit according to the provided diagram. Photos are provided as a reference. Double check your wiring before applying power. Load the sketch onto the ATTiny85 and try it out. Get it working to your satisfaction. Adjust sketch parameters as you wish.

Once it operates to your satisfaction, build the circuit on the prototype board. The small size of the board makes this challenging.

I recommend the following assembly order:

  1. 3D-print the parts for the enclosure, base and back covers. I used 5% infill. I used a raft in the final printing to keep the back side of the enclosure nice and true. Set up as you prefer. (There are two versions of the back covers."HighProfile" covers give more space for your circuit board to extend out of the main enclosure.)
  2. Assemble the base and enclosure with a bit of epoxy/glue and the 2 screws. Set aside to cure.
  3. Solder/wire the OUTPUT connections of the BOTTOM display to the INPUT connections of the top display.
  4. Solder short length wires(~40mm) to the connections on the BOTTOM display.
  5. Cut your prototype board to size and solder on the components as per the photos. It's going to be a tight fit.
  6. For your potentiometer (A2), buzzer (GPIO1), VCC and GND, use wires about 80mm long that you can feed through the hole in the base when finishing wiring.
  7. Feed the displays into place from the back of the enclosure, routing the wires joining the display through the channel in the middle of the enclosure.
  8. Solder your circuit board to the 5 wires coming from the bottom of the display as per the circuit diagram.
  9. Feed the potentiometer, buzzer, VCC and GND wires down through the hole in the base. Solder them to the potentiometer, buzzer and switch as per the diagram.You'll see I soldered the 200 Ohm resistor to the positive size of the buzzer rather than on the circuit board. Do whichever way works for you.
  10. Solder your battery holder leads to the switch and GND wires as per the diagram.
  11. Double check your wiring.
  12. Power on your circuit.

Use Your Hourglass

With it built and assembled, try it out. The start/stop button will pause/resume the countdown each time you press it. The Reset button will reset the timer.

I hope it gives you many hours of enjoyment. I think the design has a bit of an Art Deco look which I like.

One of my colleages said, "It has to be cool because my 4 year old child DEMANDED to watch the demo video 5 times." I figure if a 4 year old thinks it's cool, it's a victory.


NOW GO AN MAKE SOMETHING WONDERFUL!