Start Bootstrap

Output devices

Week 11


For this week I decided to do a project using as outputs LEDs.

So far I had just added 2 leds to my Hellow-World board. Now my idea is to add 12 LEDs and make a clock that blinks and turns on depending on the hours they are.

First I looked for some projects on the internet. Like these:


I want to use the attiny44 on my board and 12 LEDs.

This is a difficult task, because Attiny does not have enough free outputs to put the 12 LEDs.

That's why I've been investigating Charlieplexing which is a technique where we can connect multiple components using a few I / O pins in a microcontroller through an array.

You can find more explanations about the Charlieplexing here.

There are several examples on the internet of how to use 6 LEDs, 10LEDS, 12LEDS, 24LEDS, among others using only 3 pins in the microcontroller.

I did some sketches on paper, to understand the operation of the paired leds on a few output pins.

From the diagrams I made, I figured out the best way to put the 12 LEDs on the watch (12 leds are equivalent to 12 hours)

And I started to draw the layout of my badge on the Eagle program.


I did the board scheme on eagle with the following components:

  • Attiny44
  • 1uF Capacitor
  • Coin Cell Battery Holder
  • 6 LEDs connected to 1 resistor 10k
  • 6 LEDs connected to 1 resistor 10k
  • AvrISP SMD
  • Bhutan slip on / off

  • Then I designed the board, so that the 12 LEDs were around a circle.

    I wanted to use a one button battery to turn off the clock, which would be placed on the back of the clock.

    So I drew the board on two sides, front and back.

    Then I passed the layout of the board to the illustrator program so that the tracks between the components and the LEDs were circular and looked good.

  • The yellow lines correspond to the front of the board.
  • The blue lines correspond to the back of the board.
  • The red lines correspond to the cuts of the board, the outer line and the connection holes of the components.

  • I exported the drawing in SVG, and I went to the software Easel.Inventables.

    I separated the 3 different phases of cut of the board in 3 files and had cut in the milling machine Carvey.


    This is the result of my watch after being cut.

    Now it's time to start soldering the components.

    I have to pay attention to the polarity of the LEDs when soldering them, because it will make a difference when programming.

    All LEDs on the same lane must be positive and negative facing opposite sides.

    The first version of my watch had a drawing error.

    So I made a second version of the watch, which soldered the components, but some lines between the components were too thin, and I had problems when I tried to program the watch.

    I ended up doing a third version with more attention.

    The following pictures show the various attempts until you reach the final clock.


    To program the board, I plugged in USBtinyISP, just as I had done in week 8 and ran the Blink sample to see if there is no communication error.

    In my watch, I am using 3 pins of Attiny output and 2 resistors to control 12 LEDs.

    Each pin is connected to 4 different Leds. And 2 of these LEDs are connected to one resistor and the other two to another resistor.

    As we can see in the figure on the side.

    To start programming, it was necessary to make a matrix, to separate all the LEDs, and to make them light them every hour.

    The 2 resistors are defined as:

  • B00001000 = PA3 (pin A3 Arduino)
  • B00000100 = PA2 (Arduino A2 pin)

  • The 3 output pins of the LEDS are defined as:

  • B0001 = PB0 (pin 10 Arduino)
  • B0010 = PB1 (pin 9 Arduino)
  • B0100 = PB2 (pin 8 Arduino)

  • The combined connections according to the code will cause the 12 LEDs to light, one at a time.

    I wrote the following code for my watch.

    * It is necessary to download the "Time-master" library for the Arduino and #include TimeLib.h. Download here!

  • Download the code to use, here: week11_watch.gcode _3D print, Arduino file

  • The first experiences I made with the LEDs, went well, although some LEDs are switched and some LEDs light up two at a time.

    The video shows the problem.

    I switched the LEDs and fixed some connections with the GND that were in conflict. And everything went well :)


    After that, because I wanted a real watch, I printed on the 3D printer a cover for the watch, and I checked the watch.

    On the back has a battery and an on / off button to turn the clock on or off.

    I also wanted to make a bracelet for my watch.

    I bought a strip of cork, and stitched it with a line to my watch.

    The photo on the left shows the materials I used.

    Perfect :)


    How does the clock display the time?

    My first idea was to present the hours as a permanent LED on and display the minutes as a led flashing.

    However I realized, that using CHARLIEPLEXING to connect the various LEDs, I can not get two LEDs on at the same time. What a bummer!

    The solution would be to turn on and off too quickly the LEDs to imply that the LEDs were both on. This made the process more complicated, so I changed my strategy.

    My second idea was to keep the clock always off and when turned on would make an animation that would show the hours first and then the minutes they were.

    The video shows how the clock shows the hours. It's 2h30m

    What happens:

  • the watch is switched on
  • an animation runs through all the leds in a circle to one side and then to the other
  • then flashes LED 2 (which means 2 hours)
  • then flasehs LED 6 (which means it is 30 minutes)
  • and back off

  • When the watch reconnects, shows the new time.