{"id":3437,"date":"2011-12-31T19:52:04","date_gmt":"2012-01-01T01:52:04","guid":{"rendered":"http:\/\/gregsowell.com\/?p=3437"},"modified":"2011-12-31T19:52:04","modified_gmt":"2012-01-01T01:52:04","slug":"computer-controlled-christmas-lights","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=3437","title":{"rendered":"Computer Controlled Christmas Lights"},"content":{"rendered":"<p>You know it was inevitable&#8230;I can&#8217;t help myself.<\/p>\n<p>I already had a <a href=\"http:\/\/www.electronickits.com\/kit\/complete\/elec\/ck1610.htm\">ck1610 serial relay controller<\/a>&#8230;as well as an old junk laptop&#8230;so I married the two together for Christmas this year.<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/www.electronickits.com\/kit\/complete\/elec\/ck1610a.jpg\" title=\"ck1610\" class=\"alignnone\" width=\"478\" height=\"345\" \/><br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/www.electronickits.com\/kit\/complete\/elec\/ck1610.jpg\" title=\"ck1610\" class=\"alignnone\" width=\"539\" height=\"430\" \/><br \/>\nThis is a serially controlled 8 relay 2 opto-isolated input device.  You throw a serial command at it and it will kick on a relay.  Throw another and it will turn the relay off&#8230;pretty simple.<\/p>\n<p>What I did was wire a common 120V cord into the relays and ran each relay to a separate electrical outlet.  This way I can selectably power on 8 different strings of Christmas lights.  These relays are rated for 120V 15A, which is FAR more amperage than I need for my LED Christmas lights.<\/p>\n<p><figure id=\"attachment_3439\" aria-describedby=\"caption-attachment-3439\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0346.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0346.png\" alt=\"\" title=\"IMAG0346\" width=\"640\" height=\"383\" class=\"size-full wp-image-3439\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0346.png 640w, https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0346-300x179.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-3439\" class=\"wp-caption-text\">Each leg wired into a relay<\/figcaption><\/figure><br \/>\n<a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0344.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0344.png\" alt=\"Wirenutting everything together.\" title=\"IMAG0344\" width=\"640\" height=\"383\" class=\"aligncenter size-full wp-image-3440\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0344.png 640w, https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0344-300x179.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><br \/>\n<figure id=\"attachment_3441\" aria-describedby=\"caption-attachment-3441\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0343.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0343.png\" alt=\"\" title=\"IMAG0343\" width=\"640\" height=\"383\" class=\"size-full wp-image-3441\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0343.png 640w, https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0343-300x179.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-3441\" class=\"wp-caption-text\">You can see that I wirenutted the original cord end back on.  I plug the wall wart for the relay module into this port...I&#039;m oh so crafty.<\/figcaption><\/figure><br \/>\n<figure id=\"attachment_3442\" aria-describedby=\"caption-attachment-3442\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0342.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0342.png\" alt=\"\" title=\"IMAG0342\" width=\"640\" height=\"383\" class=\"size-full wp-image-3442\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0342.png 640w, https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0342-300x179.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-3442\" class=\"wp-caption-text\">Individually labeled outlets wired in.<\/figcaption><\/figure><br \/>\n<figure id=\"attachment_3443\" aria-describedby=\"caption-attachment-3443\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0341.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0341.png\" alt=\"\" title=\"IMAG0341\" width=\"640\" height=\"383\" class=\"size-full wp-image-3443\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0341.png 640w, https:\/\/gregsowell.com\/wp-content\/uploads\/2011\/12\/IMAG0341-300x179.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-3443\" class=\"wp-caption-text\">All of the outlets hooked up.<\/figcaption><\/figure><\/p>\n<p><strong>IF THE VIDEOS DON&#8217;T SHOW UP, HIT REFRESH.<\/strong><br \/>\nHere&#8217;s a video of me testing the unit:<br \/>\n<iframe loading=\"lazy\" width=\"640\" height=\"480\" src=\"http:\/\/www.youtube.com\/embed\/GxxKOWSUYXw\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>Once I got done testing I put the serial device into a NEMA enclosure to keep little fingers out of it.  I then dropped the whole thing plus the laptop into a rubbermaid tub in my garage.  And awaaaaay it goes.<\/p>\n<p>Here&#8217;s a video of my &#8220;Random Lights&#8221; program running:<br \/>\n<iframe loading=\"lazy\" width=\"853\" height=\"480\" src=\"http:\/\/www.youtube.com\/embed\/z29JCph0ccM\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\nI wrote a program to do some random control.  What it does is randomly pick a number of strings to turn on: 1 to 8.<br \/>\nIt then randomly choose which strings will be the ones to turn on.<\/p>\n<p><strong>RandomRelays Code:<\/strong><\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">#Region ;**** Directives created by AutoIt3Wrapper_GUI ****\r\n#AutoIt3Wrapper_UseX64=n\r\n#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****\r\n\r\n$RelayNumber = 0\r\ndim $NumberOfRelays[9]\r\n$NumberOfRelays[0] = 0\r\n$com = ObjCreate (&quot;NETCommOCX.NETComm&quot;)\r\n\r\n_OpenCom()\r\n\r\n\r\nwhile 1\r\n\t;turn all relays off\r\n\t$NumberOfRelays[0] = Random(1,8, 1)\r\n\t$NumberOfRelays[1] = 0\r\n\tfor $x = 1 to $NumberOfRelays[0]\r\n\t\t;this creates a random number of relays to enable\r\n\t\tif $NumberOfRelays[0] == 8 Then\r\n\t\t\t$CheckIt = 1\r\n\t\tElse\r\n\t\t\t$CheckIt = 0\r\n\t\tEndIf\r\n\t\twhile $CheckIt = 0\r\n\t\t\t$tRelay = Random(1,8,1)\r\n\t\t\t$foundMatch = 0\r\n\t\t\tfor $y = 1 to $x\r\n\t\t\t\t;make sure the same relay wasn&#039;t selected\r\n\t\t\t\tif $tRelay == $NumberOfRelays[$y] then\r\n\t\t\t\t\t; match so we have to do it again\r\n\t\t\t\t\t$foundMatch = 1\r\n\t\t\t\tEndIf\r\n\r\n\t\t\tNext\r\n\t\t\tif $foundMatch == 0  Then\r\n\t\t\t\t;we have a new value\r\n\t\t\t\t$CheckIt = 1\r\n\t\t\tEndIf\r\n\t\tWEnd\r\n\t\t$NumberOfRelays[$x] = $tRelay\r\n\tNext\r\n\t_RelayOff()\r\n\t_RelayOn()\r\n\t;random number generate, then kick on those relays\r\n\tsleep(2000) ;sleep for 1 second\r\n\r\nWEnd\r\n\r\nfunc _OpenCom ()\r\n$com.CommPort = 1\r\n$com.PortOpen = True\r\n$com.Settings = &quot;9600,N,8,1&quot;\r\n$com.InBufferCount = 0\r\nendFunc\r\n\r\nfunc _RelayOn ()\r\n\tif $NumberOfRelays[0] == 8 Then\r\n\t\t$com.Output = &quot;N0&quot; &amp; @CRLF\r\n\t\tToolTip($NumberOfRelays[0],0,0)\r\n\tElse\r\n\t\t$justatemp = $NumberOfRelays[0]\r\n\t\tfor $x = 1 to $NumberOfRelays[0]\r\n\t\t\t$justatemp = $justatemp &amp; &quot;-&quot; &amp; $NumberOfRelays[$x]\r\n\t\t\t$com.Output = &quot;N&quot; &amp; $NumberOfRelays[$x] &amp; @CRLF\r\n\t\t\tsleep(5)\r\n\t\tNext\r\n\t\tToolTip($justatemp,0,0)\r\n\tEndIf\r\n\r\nEndFunc\r\n\r\nFunc _RelayOff ()\r\n\t$com.Output = &quot;F0&quot; &amp; @CRLF\r\n\tsleep(5)\r\nEndFunc<\/code><\/pre>\n<p>RandomRelays Binary &#8211; <div class=\"wp-block-button\">\n<a  data-e-Disable-Page-Transition=\"true\" class=\"dlm-download-link dlm-download-default wp-block-button__link wp-element-button\" title=\"\" href=\"https:\/\/gregsowell.com?download=5715&amp;tmstv=1784648928\" rel=\"nofollow\" id=\"download-link-5715\" data-redirect=\"false\" >\n\tRandomRelays\t(1261 downloads\t)\n<\/a>\n<\/div>\n<\/p>\n<p>The RandomRelays program also requires the <a href=\"http:\/\/home.comcast.net\/~hardandsoftware\/NETCommOCX.htm\">NetCommOCX program from here<\/a>.<\/p>\n<p>I ran short on time this year, but I have some interesting plans for this next year, so until then, enjoy the randomness \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You know it was inevitable&#8230;I can&#8217;t help myself. I already had a ck1610 serial relay controller&#8230;as well as an old junk laptop&#8230;so I married\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,20],"tags":[],"class_list":["post-3437","post","type-post","status-publish","format-standard","hentry","category-fun","category-hardware"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/3437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3437"}],"version-history":[{"count":13,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/3437\/revisions"}],"predecessor-version":[{"id":3455,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/3437\/revisions\/3455"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}