A Christmas tree PCB ornament
14 December 2016
It is soon Christmas and I am facing the very same, yearly recurring problem: What gifts to buy! I generally prefer gifts to have a personal touch and was always fascinated by some personalized keychains I would receive from my uncle who has a milling machine. This Christmas, I did some timely planning and created a bunch of interactive electronic ornaments, shaped like Christmas trees!
These gadgets are perfect for the occasion: They are festive, easy to make, special and with the help of my newly acquired 3D printer, they can be personalized! Before beginning, I compiled a set of requirements the system should satisfy:
- Should be visually attractive
- Must be simple to use
- Must use a battery, the smallest and cheapest the better
- Should use cheap and easy to source components
- Should be hackable and reprogrammable to encourage tinkering
Based on the above, a Christmas tree shaped PCB board with an ATTiny25 microcontroller that controls different LED lamps was created! To begin with, the tree shape is easy to design and is very relevant to the whole occasion. Next, I needed to choose a microcontroller.
I wanted something cheap to begin with, so my first thought was to use the ATMega32A-AU. Strange choice you might think, but I should inform you that I already have many of them, as I bought them by accident (mistaking them for ATMega32U4) from Huaqiangbei while I was in Shenzhen. However, this thought was quickly abandoned as the particular MCU is not particularly power efficient and due to the fact that is not the most widely used, I would have to spend time digging into its datasheet in order to program it. Therefore, while it might have been the cheapest solution, it would not be the most low power or most hacker friendly. Instead, I went to a local shop that sells electronics and looked for the cheapest AVR microcontroller they had in stock. That was the ATTiny25, with a DIP-8 package, which would additionally make it easily solderable and removable if a socket is used. The ATTiny25 is essentially a cousin of the very popular ATTiny85 that I have previously used (, ), with less memory. In this case, little memory is not a show stopper for us, as nothing particularly complex or excessive needs to be performed.
In order to satisfy the low power requirements of the system in a limited space, one option would be to use a small LiPo battery. However, those are rather expensive and would require extra hardware to be recharged. A much more convenient alternative is the CR2032 coin cell battery which was chosen as the power source. Furthermore, the microcontroller should always remain in deep sleep, until a button is pressed by the user. Then a light blinking sequence will be commenced after which the MCU will go back to sleep. I had never put an ATTiny to sleep before and for it to wake up using an external interrupt, but fortunately Nick Gammon had already covered that topic for me. Additionally, as I did not want to drive 7 LEDs direcrly from the pins of the microcontroller (even though that would probably not be a problem, as the LEDs are not all turned on at the same time) the 2N7000 MOSFETs were used. MOSFETs were preferred instead of NPN transistors as they do not consume any significant power while not being triggered.
That was about it! All the requirements were fulfilled by the system and the code was practically already written for me. The PCB was quickly designed in Eagle and the Gerber files were sent to China for fabrication. For this part of the project, I used PCBway. I have used them on numerous occasions in the past as they are cheap, produce high quality boards, have very responsive customer service (with very good English!) but most importantly, are REALLY fast. Their regular fabrication process takes only a couple of days. So whenever I choose my boards to be delivered with a courier service, I get them in less than a week after I have placed the order! On the board itself, which was very nicely cut by PCBway, you can read “Happy New Year” in the different mother tongues of my girlfriend and I; Greek, Swedish, Romanian and Serbian. Note that the Greek letters are capitalized as I had trouble using Greek-specific characters. For example, what looks like an “Λ” is a “V” upside down. :-)
As the tree is more exciting standing up, I used my 3D printer to print out a base for it. When given as a gift, the receiver’s name will be printed on the base, so to personalize it at an even greater extent! To conclude, I consider this as an easy to make, relatively inexpensive, highly personal gift. I found designing the PCB to be aesthetically pleasing somewhat challenging, as well as the code to put the microcontroller in deep sleep very interesting. I should be using that technique more often from now on.
All the related source code for the firmware, the PCB and the 3D printable base, can be found on the project’s repo on GitHub, published under an MIT license. A short tutorial on how to reproduce this project was featured at Instructables. Finally, have a look at the Xmas PCB tree in action!