{"id":8116,"date":"2013-12-16T13:24:29","date_gmt":"2013-12-16T18:24:29","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=8116"},"modified":"2016-12-20T12:17:29","modified_gmt":"2016-12-20T17:17:29","slug":"making-a-mini-led-christmas-tree","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/making-a-mini-led-christmas-tree\/","title":{"rendered":"Making a mini LED Christmas tree"},"content":{"rendered":"<p>My two and a half year old son loves toys with flashing lights. For this Christmas I thought of making a mini LED Christmas tree for him. This project uses 22 multi-color LEDs which are driven by a PIC12F683 microcontroller using the Charlieplexing technique. The details of the build procedure is described in the following sections.<\/p>\n<div id=\"attachment_8126\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8126\" class=\"size-full wp-image-8126\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeTitle.jpg\" alt=\"LED Christmas tree\" width=\"570\" height=\"938\" \/><\/a><p id=\"caption-attachment-8126\" class=\"wp-caption-text\">LED Christmas tree<\/p><\/div>\n<p><!--more--><br \/>\n<strong>Christmas tree control circuit<\/strong><\/p>\n<p>This section describes the electronics part of the project. It uses the PIC12F683 microcontroller that operates at 4.0MHz using the internal clock source and drives 20 LEDs through 5 I\/O pins (GP0, GP1, GP2, GP4, and GP5) using the Charlieplexing technique. The 20 LEDs are connected to the five Charlieplexing signal lines (named A through E) as shown in the figures below. Multiple color LEDs are chosen to make the Christmas tree colorful and attractive.<\/p>\n<div id=\"attachment_8132\" style=\"width: 544px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8132\" class=\"size-full wp-image-8132\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree1.jpg\" alt=\"Microcontroller circuit with five Charlieplexing lines\" width=\"534\" height=\"423\" \/><\/a><p id=\"caption-attachment-8132\" class=\"wp-caption-text\">Microcontroller circuit with five Charlieplexing lines<\/p><\/div>\n<div id=\"attachment_8133\" style=\"width: 585px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8133\" class=\"size-full wp-image-8133\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree2.jpg\" alt=\"Microcontroller circuit with five Charlieplexing lines\" width=\"575\" height=\"358\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree2.jpg 575w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTree2-550x342.jpg 550w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/a><p id=\"caption-attachment-8133\" class=\"wp-caption-text\">20 LEDs connected to the signal lines A through E<\/p><\/div>\n<p><strong>Construction of tree<\/strong><\/p>\n<p>First of all, make a paper layout of the tree and stick it on a cardboard or a foam board using glue. I am using the 0.2&#8243; thick black foam board from Dollar Tree. Mark the places where you want to place LEDs on your Christmas tree. Next drill two holes (approximately 0.1&#8243; apart) for LED legs at each marked LED position. Then cut the foam board along the layout of the tree. These steps are illustrated in the following pictures.<\/p>\n<div id=\"attachment_8118\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8118\" class=\"size-full wp-image-8118\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout1.jpg\" alt=\"Layout of Christmas tree\" width=\"570\" height=\"760\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout1.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout1-487x650.jpg 487w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8118\" class=\"wp-caption-text\">Layout of Christmas tree<\/p><\/div>\n<div id=\"attachment_8119\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8119\" class=\"size-full wp-image-8119\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout2.jpg\" alt=\"Drilling holes at LED positions\" width=\"570\" height=\"455\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout2.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout2-550x439.jpg 550w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8119\" class=\"wp-caption-text\">Drilling holes at LED positions<\/p><\/div>\n<div id=\"attachment_8120\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8120\" class=\"size-full wp-image-8120\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout3.jpg\" alt=\"Christmas tree base ready\" width=\"570\" height=\"400\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout3.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout3-550x385.jpg 550w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8120\" class=\"wp-caption-text\">Christmas tree base ready<\/p><\/div>\n<p>Next take a construction paper (I am using Green color) for the front view of the tree. You can glue the cut foam board tree to it first and then cut the paper along the edges of the foam board. Now you will have a more colorful front look for the tree, as shown below.<\/p>\n<div id=\"attachment_8123\" style=\"width: 574px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout6.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8123\" class=\"size-full wp-image-8123\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout6.jpg\" alt=\"Finished tree base\" width=\"564\" height=\"407\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout6.jpg 564w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLayout6-550x396.jpg 550w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/a><p id=\"caption-attachment-8123\" class=\"wp-caption-text\">Finished tree base<\/p><\/div>\n<p>The holes for LEDs are covered on the top with the newly added layer of the construction paper. You can extend these holes across the construction paper by inserting a sharp pin through each hole\u00a0from back side to the front. Next insert LEDs from front side and bend their legs on back side for their support. The following picture shows the arrangement of LEDs in my Christmas tree. I put 11 5.0mm Red color LEDs (1-11) along the edges, and 11 more (multi-color) in the body area of the tree. This makes total 22 LEDs. The LEDs marked 1 through 20 are connected to the Charlieplexing circuit (discussed above) in the same way as described in the circuit diagram. LED 21 is connected in parallel with LED 16, and LED 22 is connected in parallel with LED 20. I added these two extra LEDs just for the symmetry of the LED distribution in the tree.<\/p>\n<div id=\"attachment_8124\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLeds.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8124\" class=\"size-full wp-image-8124\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLeds.jpg\" alt=\"LED positions and numbers\" width=\"570\" height=\"722\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLeds.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeLeds-513x650.jpg 513w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8124\" class=\"wp-caption-text\">LED positions and numbers<\/p><\/div>\n<p>Note that the LED labels (1-22) in the above picture are added later with Paint.net software for readers convenience and are not printed in the actual tree. You can also decorate your tree with various Christmas shape stickers as I did. All the LED wiring are done on back side of the tree. I fixed a small piece of general purpose prototyping board on back side that carries the five\u00a0Charlieplexing signal lines along with\u00a0100 Ohm resistors in series.\u00a0Each LED terminals should be connected to two Charlieplexing signal lines as shown in the circuit diagram before. This is the most time consuming part of this project. The second end of the five resistors are accessible through header pins on the prototyping board.<\/p>\n<div id=\"attachment_8128\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeWiring.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8128\" class=\"size-full wp-image-8128\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeWiring.jpg\" alt=\"Wiring on back side\" width=\"570\" height=\"809\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeWiring.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeWiring-457x650.jpg 457w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8128\" class=\"wp-caption-text\">Wiring on back side<\/p><\/div>\n<div id=\"attachment_8139\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/BackSideBoard.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8139\" class=\"size-full wp-image-8139\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/BackSideBoard.jpg\" alt=\"Back side board\" width=\"570\" height=\"382\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/BackSideBoard.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/BackSideBoard-550x368.jpg 550w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8139\" class=\"wp-caption-text\">Back side circuit board with headers for Charlieplexing lines<\/p><\/div>\n<p>For microcontroller part, I used the <strong><a href=\"http:\/\/embedded-lab.com\/blog\/?p=8035\" target=\"_blank\">rapidPIC-08 board<\/a>,<\/strong>\u00a0which is designed\u00a0for easy and rapid prototyping of standalone applications using PIC12F microcontrollers. You can buy <a href=\"https:\/\/www.tindie.com\/products\/rajbex\/pic12f-series-microcontrollers-project-board-kit\/\" target=\"_blank\"><strong>rapidPIC-08 development board kit on Tindie<\/strong><\/a>. The complete setup is powered with a 9V battery. For standing support, I used alligator clips from my spare extra hands soldering aid tool to hold the Christmas tree in upright position.<\/p>\n<div id=\"attachment_8125\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8125\" class=\"size-full wp-image-8125\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeSetup.jpg\" alt=\"Finished Christmas tree\" width=\"570\" height=\"836\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeSetup.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeSetup-443x650.jpg 443w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8125\" class=\"wp-caption-text\">Christmas tree and rapid PIC12F development board powered with a 9V battery<\/p><\/div>\n<p><strong>Software<\/strong><\/p>\n<p>I wrote the firmware for this project using <a href=\"http:\/\/www.mikroe.com\/mikroc\/pic\/\" target=\"_blank\"><strong>mikroC Pro for PIC<\/strong><\/a> compiler from mikroElektronika. MikroC is one of the easiest, powerful, and rich library set C compilers I have known for PIC microcontrollers. It is a commercial compiler. However, the free version allows you to compile 2K size of hex file, which is good enough for developing small applications like this. Here I have shared the source code and HEX files of my firmware that generates four LED glow patterns in sequence and then repeats after some delay (watch the video at the end). There is a lot of programming space left for adding more patterns. It is currently using only 544 program words out of 2K.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/uploads\/HexFiles\/PIC12F\/ChristmasTree.zip\" target=\"_blank\"><strong>Download source and hex files<\/strong><\/a><\/p>\n<p>The following picture shows the configuration word for the PIC12F683 MCU in this project.<\/p>\n<div id=\"attachment_8146\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/PIC12F683-CONFIG-word.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8146\" class=\"size-full wp-image-8146\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/PIC12F683-CONFIG-word.jpg\" alt=\"PIC12F683 configuration\" width=\"565\" height=\"380\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/PIC12F683-CONFIG-word.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/PIC12F683-CONFIG-word-550x369.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-8146\" class=\"wp-caption-text\">PIC12F683 configuration<\/p><\/div>\n<p><strong><span style=\"font-size: 0.95em; line-height: 1.6em;\">Output<\/span><\/strong><\/p>\n<p>The mini LED Christmas tree is now shining in our living room. My son loves it.<\/p>\n<div id=\"attachment_8126-2\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8126-2\" class=\"size-full wp-image-8126\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ChristmasTreeTitle.jpg\" alt=\"LED Christmas tree\" width=\"570\" height=\"938\" \/><\/a><p id=\"caption-attachment-8126-2\" class=\"wp-caption-text\">LED Christmas tree with all LEDs on<\/p><\/div>\n<div id=\"attachment_8147\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ReyPlaying.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8147\" class=\"size-full wp-image-8147\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ReyPlaying.jpg\" alt=\"My son (Rey) playing with his new Christmas toy\" width=\"570\" height=\"453\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ReyPlaying.jpg 570w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/12\/ReyPlaying-550x437.jpg 550w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/a><p id=\"caption-attachment-8147\" class=\"wp-caption-text\">My son (Rey) playing with his new Christmas toy<\/p><\/div>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/b6NLVB9jqVs\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>My two and a half year old son loves toys with flashing lights. For this Christmas I thought of making a mini LED Christmas tree for him. This project uses 22 multi-color LEDs which are driven by a PIC12F683 microcontroller using the Charlieplexing technique. The details of the build procedure is described in the following sections.<\/p>\n","protected":false},"author":1,"featured_media":8126,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[245,4],"tags":[700,699,6],"class_list":["post-8116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded-lab-projects","category-pic-projects","tag-charlieplexing","tag-led-christmas-tree","tag-pic12f683"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/8116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=8116"}],"version-history":[{"count":19,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/8116\/revisions"}],"predecessor-version":[{"id":12907,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/8116\/revisions\/12907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/8126"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=8116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=8116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=8116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}