No more getting troubled on what Christmas gifts to get! These personalized PCB ornaments will leave everybody satisfied & inspired to hack!
Before we begin with the instructions, a little bit on the background, as published on my blog:
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 preffered 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 the MIT license.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Personalize the Design
Changing the existing design is relatively easy. You probably want to add your own text on the board. So, here's what you need to do:
- Download the schematic and board file that can be found in the project's GitHub repository and particularly the eagle folder.
- Open the files in Eagle.
- Go to the window with the board (xmas_tree.brd) file.
- Click on the Info tool.
- Click on the cross right beneath the text you want to edit.
- Change the text and/or font size.
- Do not forget to remove the stray upside down "V" that can be found on the first line, using the delete tool.
Feel free of course to change anything else you wish in the design and the schematic. Eagle is relatively easy to use, especially if you only need to make small changes in an already existing design.
Step 2: Fabricate the Board
OSH Park accepts .brd files, so you do not need to do much more other than uploading your .brd file, reviewing the boards and placing your order.
Step 3: Necessary Components
After ordering the boards, you will be receiving them in about 20-30 days if you chose the normal shipping or in about a week, if you opted for the expedited shipping with a courrier. I ordered mine on a Tuesday and got them the coming Monday from PCBway.
Then you will need to do solder the necessary components to the board. I have included the necessary materials on the project's hackster.io page so please refer to that.
Furthermore, it is probably not a good idea to solder directly the microcontroller on the board. Instead, attach it to a socket so you can remove if necessary (e.g. to easily program it or reuse it elsewhere).
You will need a 3D printer if you want to get the base as well. I have included the 3D model on the GitHub repository.
Step 4: Programming the ATTiny
Finally, if everything went well, you should be standing with a fully assembled board. Now, all you need to make the magic happen is software! The tricky parts of the code are well commented and feel absolutely free to experiment by adding your own implementation in there.
There are many good tutorials around on how to program the ATTiny25/45/85 so I will not write a new one. The one I have personally found most useful is the one by High Low Tech. To make your life even easier, you could consider investing in a programming shield. And that was all!
Best of luck, have fun and give the people you care about a special gift they will always remember! Merry Christmas and a happy New Year!
Participated in the
Homemade Gifts Contest 2016