{"id":52,"date":"2015-04-10T20:18:27","date_gmt":"2015-04-10T20:18:27","guid":{"rendered":"https:\/\/hughqelliott.com\/blog\/?p=52"},"modified":"2015-04-10T20:18:27","modified_gmt":"2015-04-10T20:18:27","slug":"clock-build","status":"publish","type":"post","link":"https:\/\/hughqelliott.com\/blog\/clock-build\/","title":{"rendered":"Clock Build"},"content":{"rendered":"<p>As <a title=\"Infinity Mirror Build\" href=\"https:\/\/hughqelliott.com\/blog\/infinity-mirror-build\/\">previously-mentioned<\/a>\u00a0I have an abundance of <a title=\"LPD8806\" href=\"http:\/\/www.adafruit.com\/product\/306\" target=\"_blank\">RGB LED strips<\/a>. I don&#8217;t intend to buy more unless I&#8217;m putting on a workshop. So I might as well figure out little projects to play with LEDs I have.<\/p>\n<p>I have designed some watches in collaboration with my good friend, Scott Wilk of <a title=\"Wilk Watchworks collaboration\" href=\"http:\/\/wilkwatchworks.com\/product-tag\/moviesinhaiku\/\" target=\"_blank\">Wilk Watchworks<\/a>\u00a0and in the back of my mind is always &#8220;It would be cool to have a clock that is all &#8216;future-y'&#8221; (insert air quotes).<\/p>\n<figure style=\"width: 300px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"http:\/\/wilkwatchworks.com\/wp-content\/uploads\/2013\/07\/circlepack1-300x300.jpg\" alt=\"A very cool watch\" width=\"300\" height=\"300\" \/><figcaption class=\"wp-caption-text\">Circle-packing Watch<\/figcaption><\/figure>\n<p>The strip I have is paired RGB LEDs separated by a shift register in a line. I didn&#8217;t really dig on how far apart the LEDs in each pair so I thought, &#8220;Cut pairs out, solder the ends and I can tighten the lines up.&#8221;<\/p>\n<blockquote class=\"instagram-media\" style=\"background: #FFF; border: 0; border-radius: 3px; box-shadow: 0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width: 658px; padding: 0; width: calc(100% - 2px);\" data-instgrm-version=\"4\">\n<div style=\"padding: 8px;\">\n<div style=\"background: #F8F8F8; line-height: 0; margin-top: 40px; padding: 50% 0; text-align: center; width: 100%;\"><\/div>\n<p style=\"color: #c9c8cd; font-family: Arial,sans-serif; font-size: 14px; line-height: 17px; margin-bottom: 0; margin-top: 8px; overflow: hidden; padding: 8px 0 7px; text-align: center; text-overflow: ellipsis; white-space: nowrap;\"><a style=\"color: #c9c8cd; font-family: Arial,sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 17px; text-decoration: none;\" href=\"https:\/\/instagram.com\/p\/y40nbnklwG\/\" target=\"_top\">A photo posted by Hugh Elliott (@hughqelliott)<\/a> on <time style=\"font-family: Arial,sans-serif; font-size: 14px; line-height: 17px;\" datetime=\"2015-02-09T16:53:58+00:00\">Feb 9, 2015 at 8:53am PST<\/time><\/p>\n<\/div>\n<\/blockquote>\n<p><script src=\"\/\/platform.instagram.com\/en_US\/embeds.js\" async=\"\" defer=\"defer\"><\/script>I decided to make two rows of 30 LEDs. My thinking was for a second counter, It could run down\u00a0the length, then back up to the top. So began a fun game I call\u00a0<em>solder and test.\u00a0<\/em>In this game, I would solder the four wires to add to the sequence, then plug the strip in to the Arduino and test the strip to that point. Honestly, in retrospect, I could have just touched four leads to the strip pair and determined if I had a burnt LED. Live and learn, people.<\/p>\n<blockquote class=\"instagram-media\" style=\"background: #FFF; border: 0; border-radius: 3px; box-shadow: 0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width: 658px; padding: 0; width: calc(100% - 2px);\" data-instgrm-version=\"4\">\n<div style=\"padding: 8px;\">\n<div style=\"background: #F8F8F8; line-height: 0; margin-top: 40px; padding: 50% 0; text-align: center; width: 100%;\"><\/div>\n<p><a style=\"color: #c9c8cd; font-family: Arial,sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 17px; text-decoration: none;\" href=\"https:\/\/instagram.com\/p\/y5i6tykl8n\/\" target=\"_top\">A photo posted by Hugh Elliott (@hughqelliott)<\/a> on <time style=\"font-family: Arial,sans-serif; font-size: 14px; line-height: 17px;\" datetime=\"2015-02-09T23:38:33+00:00\">Feb 9, 2015 at 3:38pm PST<\/time>\n<\/div>\n<\/blockquote>\n<p><script src=\"\/\/platform.instagram.com\/en_US\/embeds.js\" async=\"\" defer=\"defer\"><\/script><\/p>\n<p>&nbsp;<\/p>\n<p>I needed enough wire to be able to turn the strip pairs in line with each other but not so much that I&#8217;d have excess wire. Because why make things easy?<\/p>\n<figure id=\"attachment_56\" aria-describedby=\"caption-attachment-56\" style=\"width: 744px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/IMG_1002.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-56 size-medium\" src=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/IMG_1002-e1428694773704-744x624.jpg\" alt=\"Twist in the wind!\" width=\"744\" height=\"624\" srcset=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/IMG_1002-e1428694773704-744x624.jpg 744w, https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/IMG_1002-e1428694773704-420x352.jpg 420w, https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/IMG_1002-e1428694773704-1200x1006.jpg 1200w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/a><figcaption id=\"caption-attachment-56\" class=\"wp-caption-text\">Twist in the wind!<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>Once I had my 30 pairs tested I moved on to the code. I started by trying the <a title=\"Delay function\" href=\"http:\/\/arduino.cc\/en\/reference\/delay\" target=\"_blank\">delay function<\/a> in Arduino. Nice thought, of course. &#8220;I&#8217;ll just run my function once a second. Or hmm\u2026 once every 500 milliseconds. Or wow\u2026 that&#8217;s not right\u2026 250 milliseconds.&#8221; In theory delay(numValue); seems like a great idea. What happens when whatever you need to run each second takes a millisecond or two every cycle? You lose time. If you leave a clock running that loses time gradually, you end up with a crappy clock.<\/p>\n<p>So that lead me to <a title=\"RTClib\" href=\"https:\/\/github.com\/adafruit\/RTClib\" target=\"_blank\">RTClib<\/a>. This is nice little library specifically for date and timekeeping. If your functions take up extra cycles to run, you don&#8217;t lose accuracy because RTClib tracks the time for you. Super handy.<\/p>\n<p>&nbsp;<\/p>\n<p>For the clock display, I implemented a standard one-LED second, one-LED minute and a five-LED hour. Why five? 60\/12 = 5. Every five LEDs is an hour. For my LEDs to run correctly I had to set up a pair of arrays, one for seconds (additionally used by minutes) and one for hours. Remember that LED strips work in sequence. So to light a typical LED strip in order, you&#8217;d target led[0], led[1], led[2]. In my case, however, my ordering winds back and forth. Check out my arrays.<\/p>\n<p><code>int secondsPositions[] = {0 , 3 , 4 , 7 , 8 , 11 , 12 , 15 , 16 , 19 , 20 , 23 , 24 , 27 , 28 , 31 , 32 , 35 , 36 , 39 , 40 , 43 , 44 , 47 , 48 , 51 , 52 , 55 , 56 , 59 , 58 , 57 , 54 , 53 , 50 , 49 , 46 , 45 , 42 , 41 , 38 , 37 , 34 , 33 , 30 , 29 , 26 , 25 , 22 , 21 , 18 , 17 , 14 , 13 , 10 , 9 , 6 , 5 , 2 , 1};<\/code><\/p>\n<p><code>int hoursPositions[][12] = {{0 , 3 , 4 , 7 , 8} , {11 , 12 , 15 , 16 , 19} , {20 , 23 , 24 , 27 , 28} , {31 , 32 , 35 , 36 , 39} , {40 , 43 , 44 , 47 , 48} , {51 , 52 , 55 , 56 , 59} , {58 , 57 , 54 , 53 , 50} , {49 , 46 , 45 , 42 , 41} , {38 , 37 , 34 , 33 , 30} , {29 , 26 , 25 , 22 , 21} , {18 , 17 , 14 , 13 , 10} , {9 , 6 , 5 , 2 , 1}};<\/code><\/p>\n<figure id=\"attachment_62\" aria-describedby=\"caption-attachment-62\" style=\"width: 744px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/LED_order.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-62 size-medium\" src=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/LED_order-744x198.jpg\" alt=\"LED_order\" width=\"744\" height=\"198\" srcset=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/LED_order-744x198.jpg 744w, https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/LED_order-420x112.jpg 420w, https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/LED_order.jpg 1000w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/a><figcaption id=\"caption-attachment-62\" class=\"wp-caption-text\">I only numbered up to 6 here but you get the idea. Whacky.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>The point, of course is when I run my clock and you look at it, it&#8217;s linear.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/vine.co\/v\/OPaXzqzTq0L\/embed\/simple\" width=\"600\" height=\"600\" frameborder=\"0\"><\/iframe><script src=\"https:\/\/platform.vine.co\/static\/scripts\/embed.js\"><\/script>\u00a0 I started to have an issue with the LED control library I was using and discovered <a title=\"FastLED\" href=\"http:\/\/fastled.io\/\" target=\"_blank\">FastLED<\/a>. It sort of took the place of the original LED library in my heart. It&#8217;s robust and supports a ton of different LED strips. Still messing with it but whatever.\u00a0 <iframe loading=\"lazy\" src=\"https:\/\/vine.co\/v\/OPWgTrExeM3\/embed\/simple\" width=\"600\" height=\"600\" frameborder=\"0\"><\/iframe><\/p>\n<p>There&#8217;s a little left on the code front I need to do. For instance, the hours don&#8217;t show up at all at midnight. Because you should be in bed, Hugh! And the minute will remove an hour LED when they occupy the same position. Other than that, I have some manual controls to add, buttons for setting the time, for instance, might be handy.<\/p>\n<p>I&#8217;ve designed the face of it and will get it laser cut. Once cut, I think I&#8217;ll apply the same mirror film I use for the infinity mirror. Ought to be a pretty cool effect. Here&#8217;s the design for the face and housing. I&#8217;ll update when I scrape together laserin&#8217; money.<\/p>\n<div id='gallery-1' class='gallery galleryid-52 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<a href='https:\/\/hughqelliott.com\/blog\/clock-build\/hughqelliott_clock14in_acrylic\/'><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"763\" src=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/HughQElliott_Clock14IN_acrylic-420x763.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-66\" srcset=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/HughQElliott_Clock14IN_acrylic-420x763.jpg 420w, https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/HughQElliott_Clock14IN_acrylic.jpg 500w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/a>\n\t\t\t<\/div>\n\t\t\t\t<figcaption class='wp-caption-text gallery-caption' id='gallery-1-66'>\n\t\t\t\tback and sides\n\t\t\t\t<\/figcaption><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<a href='https:\/\/hughqelliott.com\/blog\/clock-build\/hughqelliott_clock18in_plywood\/'><img loading=\"lazy\" decoding=\"async\" width=\"114\" height=\"500\" src=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/HughQElliott_Clock18IN_plywood.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-68\" \/><\/a>\n\t\t\t<\/div>\n\t\t\t\t<figcaption class='wp-caption-text gallery-caption' id='gallery-1-68'>\n\t\t\t\tStruts and cover\n\t\t\t\t<\/figcaption><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<a href='https:\/\/hughqelliott.com\/blog\/clock-build\/hughqelliott_clock18in_acrylic\/'><img loading=\"lazy\" decoding=\"async\" width=\"199\" height=\"500\" src=\"https:\/\/hughqelliott.com\/blog\/wp-content\/uploads\/2015\/04\/HughQElliott_Clock18IN_acrylic.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-67\" \/><\/a>\n\t\t\t<\/div>\n\t\t\t\t<figcaption class='wp-caption-text gallery-caption' id='gallery-1-67'>\n\t\t\t\tFace\n\t\t\t\t<\/figcaption><\/figure>\n\t\t<\/div>\n\n<p>&nbsp;<\/p>\n<p>Anyway, that&#8217;s the clock. If you want one, let me know, and I&#8217;ll figure out a price. It&#8217;s time-consuming but it&#8217;ll look pretty amazing.<\/p>\n<p><script src=\"https:\/\/platform.vine.co\/static\/scripts\/embed.js\" type=\"mce-no\/type\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nAs previously-mentioned\u00a0I have an abundance of RGB LED strips. I don&#8217;t intend to buy more unless I&#8217;m putting on a&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/hughqelliott.com\/blog\/clock-build\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Clock Build&rdquo;<\/span>&hellip;<\/a><\/div>\n","protected":false},"author":1,"featured_media":53,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[5,4],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-build","category-fabrication","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":9,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions\/70"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/media\/53"}],"wp:attachment":[{"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hughqelliott.com\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}