<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Uncategorized &#8211; Busy Ducks</title>
	<atom:link href="/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Making You Pro&#039;duck&#039;tive</description>
	<lastBuildDate>Tue, 21 Apr 2020 02:27:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.3</generator>

<image>
	<url>/wp-content/uploads/2015/07/cropped-favicon-55963284v1_site_icon-32x32.png</url>
	<title>Uncategorized &#8211; Busy Ducks</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Upgrading Robie The Robot.</title>
		<link>/upgrading-robie-the-robot/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 02:27:55 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D-Printing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[raspberry_pi]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[vintage]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=1018</guid>

					<description><![CDATA[Part one, in a journey to upgrade an old robot. This classic 80's robot This robot was also known as: Tandy Robie, Radio Shack Robie, Robie the Robot, Talking Robie, RS 4061, Robocom 1000, Robie Parlant, and Robocom Robot (Super).]]></description>
										<content:encoded><![CDATA[
<h2>A Rare Find</h2>



<p>I was in an vintage collectables store and saw a beaten up old &#8216;Robie the Robot&#8217; forgotten at the back of a shelf. It&#8217;s dome was cracked and it&#8217;s remote missing. Robot collectors are quite voracious in Canberra with most robots snapped up within days. However, it seems nobody relished this rough robotic remnant, so I got it cheap.</p>



<p>This robot was also known as: <em>Tandy Robie, Radio Shack Robie, Robie the Robot, Talking Robie, RS 4061, Robocom 1000, Robie Parlant, Robocom Robot (Super)</em>. There is a good write up about the robot on <a rel="noreferrer noopener" href="http://www.theoldrobots.com/talkrobie2.html" target="_blank">theoldrobots</a>.</p>



<figure class="wp-block-image size-large"><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/robbie-1024x768.jpeg" alt="" class="wp-image-1019"/><figcaption>Robie The Robot, as purchased.</figcaption></figure>



<h2>Tear Down</h2>



<p>Disassembling Robie I discovered a typical 80&#8217;s remote control toy. RC circuitry oozing with leaking capacitor electrolyte and decayed protective lacquer. Apparently the built in speaker could talk, but looking at the circuitry, my guess is it functioned as a wally talky, playing a voice signal from the remote.  I didn&#8217;t have the remote so I can&#8217;t confirm.<br><br>The motors were the &#8220;old style&#8221;; power hungry and weak. The Achilles heel that made all 80&#8217;s moving toys kinda nerfed.</p>



<p>The front screen was fake, the heads and arms were not designed to move. I will need to fix all this.</p>



<h2>A New Brain.</h2>



<p>Decided to throw a pi in there, with a monitor that fits the front screen and a camera because that would be cool. <br></p>



<figure class="wp-block-image size-large"><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/pi-1024x768.jpeg" alt="" class="wp-image-1020"/></figure>



<p>For the display, a generic five dollar 2.2&#8243; SPI TFT LCD&nbsp;that sells for arduino projects works well (fits just behind the front monitor panel). The stock plastic used for Robies display is way to dark for the screen to be visible, so I used a Fresnel lens instead (you can get them from the two dollar shop, sold a book magnifiers). </p>



<p>A front assembly was 3d printed to hold the pi, monitor and camera (such that everything lined up, and the camera could see out of the hole previously used for the frontal on/off switch.</p>



<figure class="wp-block-gallery columns-3 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="768" src="/wp-content/uploads/2020/04/front_asm_render.jpg" alt="" data-id="1021" data-link="http://busyducks.com/wp_4_1/?attachment_id=1021#main" class="wp-image-1021" srcset="/wp-content/uploads/2020/04/front_asm_render.jpg 1024w, /wp-content/uploads/2020/04/front_asm_render-300x225.jpg 300w, /wp-content/uploads/2020/04/front_asm_render-768x576.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="blocks-gallery-item__caption">Design in Fusion 360, screen is mounted on the green sled.</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4158235-768x1024.jpg" alt="" data-id="1034" data-link="http://busyducks.com/wp_4_1/?attachment_id=1034#main" class="wp-image-1034"/><figcaption class="blocks-gallery-item__caption">Rear</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4158236-768x1024.jpg" alt="" data-id="1035" data-link="http://busyducks.com/wp_4_1/?attachment_id=1035#main" class="wp-image-1035"/><figcaption class="blocks-gallery-item__caption">Front</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4158224-1024x768.jpg" alt="" data-id="1037" data-full-url="/wp-content/uploads/2020/04/P4158224-scaled-1.jpg" data-link="http://busyducks.com/wp_4_1/?attachment_id=1037#main" class="wp-image-1037"/><figcaption class="blocks-gallery-item__caption">Empty shell, wit Fresnel lens.</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4158223-1024x768.jpg" alt="" data-id="1036" data-full-url="/wp-content/uploads/2020/04/P4158223-scaled-1.jpg" data-link="http://busyducks.com/wp_4_1/?attachment_id=1036#main" class="wp-image-1036"/><figcaption class="blocks-gallery-item__caption">Mount pi.</figcaption></figure></li></ul></figure>



<h2>Motorising the Head</h2>



<p>A turntable system was created in OpenSCAD, using the awesome parametric gear library by Dr Jörg Janssen. I didn&#8217;t have a 3d printer, so I printed via the ANU Makerspace.</p>



<figure class="wp-block-gallery columns-3 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="586" src="/wp-content/uploads/2020/04/head_gears_lower-1024x586.png" alt="" data-id="1023" data-link="http://busyducks.com/wp_4_1/?attachment_id=1023#main" class="wp-image-1023" srcset="/wp-content/uploads/2020/04/head_gears_lower-1024x586.png 1024w, /wp-content/uploads/2020/04/head_gears_lower-300x172.png 300w, /wp-content/uploads/2020/04/head_gears_lower-768x439.png 768w, /wp-content/uploads/2020/04/head_gears_lower.png 1103w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" width="1024" height="691" src="/wp-content/uploads/2020/04/P6185667_close_up-1024x691.jpg" alt="" data-id="1024" data-link="http://busyducks.com/wp_4_1/?attachment_id=1024#main" class="wp-image-1024" srcset="/wp-content/uploads/2020/04/P6185667_close_up-1024x691.jpg 1024w, /wp-content/uploads/2020/04/P6185667_close_up-300x202.jpg 300w, /wp-content/uploads/2020/04/P6185667_close_up-768x518.jpg 768w, /wp-content/uploads/2020/04/P6185667_close_up-1536x1036.jpg 1536w, /wp-content/uploads/2020/04/P6185667_close_up-2048x1381.jpg 2048w, /wp-content/uploads/2020/04/P6185667_close_up-1568x1057.jpg 1568w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/inside_a-906x1024.jpg" alt="" data-id="1025" data-full-url="/wp-content/uploads/2020/04/inside_a-scaled-1.jpg" data-link="http://busyducks.com/wp_4_1/?attachment_id=1025#main" class="wp-image-1025"/></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" width="674" height="440" src="/wp-content/uploads/2020/04/head_gears_upper.png" alt="" data-id="1022" data-link="http://busyducks.com/wp_4_1/?attachment_id=1022#main" class="wp-image-1022" srcset="/wp-content/uploads/2020/04/head_gears_upper.png 674w, /wp-content/uploads/2020/04/head_gears_upper-300x196.png 300w" sizes="(max-width: 674px) 100vw, 674px" /></figure></li></ul></figure>



<p>The turntable is driven by a 28byj-48 stepper motor, with a ULN2003 Darlington transistor array driver. <br></p>



<p>I discovered the original broken dome was most likely not a custom mould,  but a security camera dome. I had some difficulty justifying a proper replacement as Australian retailers wanted over $50 for a replacement security camera dome (just the one piece of plastic). So I just replaced the head with a plastic dome from a toy shop.<br><br>The result is not quite as fast as I would like, but it was unexpectedly charming.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="P6235685" width="940" height="529" src="https://www.youtube.com/embed/sQd-v5fpN5s?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<h2>Getting the arms to move.</h2>



<p>A bracket was designed to get some cheap tower-pro servos to fit aligned with the arms. The brackets neatly affixes to old circuit mounting points in the plastic. A custom servo horn will friction fitted the arms to the servo. The existing arm bearing was sanded a bit to get it to slide freely. The result is a much more expressive robot. </p>



<figure class="wp-block-gallery columns-3 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4058095-768x1024.jpg" alt="" data-id="1026" data-link="http://busyducks.com/wp_4_1/?attachment_id=1026#main" class="wp-image-1026"/><figcaption class="blocks-gallery-item__caption">Servo mount rear</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4058096-768x1024.jpg" alt="" data-id="1027" data-link="http://busyducks.com/wp_4_1/?attachment_id=1027#main" class="wp-image-1027"/><figcaption class="blocks-gallery-item__caption">Servo mount top</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4058110-1024x768.jpg" alt="" data-id="1028" data-link="http://busyducks.com/wp_4_1/?attachment_id=1028#main" class="wp-image-1028"/><figcaption class="blocks-gallery-item__caption">friction fit arm</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4058101-1024x768.jpg" alt="" data-id="1029" data-link="http://busyducks.com/wp_4_1/?attachment_id=1029#main" class="wp-image-1029"/><figcaption class="blocks-gallery-item__caption">servos installed</figcaption></figure></li><li class="blocks-gallery-item"><figure><img src="http://busyducks.com/wp_4_1/wp-content/uploads/2020/04/P4058108-1024x768.jpg" alt="" data-id="1030" data-full-url="/wp-content/uploads/2020/04/P4058108-scaled-1.jpg" data-link="http://busyducks.com/wp_4_1/?attachment_id=1030#main" class="wp-image-1030"/><figcaption class="blocks-gallery-item__caption">servo horns installed</figcaption></figure></li></ul></figure>



<h2>Whats next.</h2>



<p>I have made files for the progress thus far available via github, encase anyone has a Robie of their own and wants to try this. <a href="https://github.com/busyDuckman/robbie">https://github.com/busyDuckman/robbie</a></p>



<p>Next up I will work on:</p>



<ul><li>Drive system so Robie can move around.</li><li>Microphone array so voice interaction is possible.</li><li>Control software.</li><li>Personality and human interaction.</li></ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is the difference between a laser that will cut metals and one that won&#8217;t?</title>
		<link>/what-is-the-difference-between-a-laser-that-will-cut-metals-and-one-that-wont/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Fri, 26 Jan 2018 04:12:23 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CAM]]></category>
		<category><![CDATA[Edcucational]]></category>
		<category><![CDATA[Laser_Cutter]]></category>
		<category><![CDATA[Manufacturing]]></category>
		<category><![CDATA[Metal-work]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=905</guid>

					<description><![CDATA[A friend who recently acquired a CO2 laser cutter for his school recently sent me a message. "What is the difference between a laser that will cut metals and one that won't?". I thought this is a good question, as the answer will help with understanding how to work with many materials.]]></description>
										<content:encoded><![CDATA[<h1>Introduction</h1>
<p>A friend who recently acquired a CO2 laser cutter for his school sent me a message. &#8220;What is the difference between a laser that will cut metals and one that won&#8217;t?&#8221;. I thought this is a good question, as the answer will help with understanding how to work with many materials.</p>
<p>But before the answer will make sense, we need to revisit the basics of how a laser cutter works in more detail.</p>
<p><figure id="attachment_906" aria-describedby="caption-attachment-906" style="width: 300px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o.jpg"><img loading="lazy" class="wp-image-906 size-medium" src="/wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-300x242.jpg" alt="" width="300" height="242" srcset="/wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-300x242.jpg 300w, /wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-1024x827.jpg 1024w, /wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-768x620.jpg 768w, /wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-1536x1240.jpg 1536w, /wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o-1568x1266.jpg 1568w, /wp-content/uploads/2018/01/1397657_10151706305006956_1694737819_o.jpg 1624w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-906" class="wp-caption-text">Nick Bannon (left) and Myself (right) [amongst others not pictured], setting up the laser cutting area at the Perth Aritifactoty &#8211; 2013.</figcaption></figure>&nbsp;</p>
<p>&nbsp;</p>
<h1>How the laser cutter works: 101</h1>
<p>The common C02 laser cutter can be thought of as &#8220;thick&#8221; beam of IR light that moves out of a laser tube, bounces of mirrors until to get to the head. In the head it passes through a lens that focuses the beam, such that it is strong enough to ablate certain material though heat. A jet of air clears debris, and if upgraded from the piddly inbuilt compressor, will minimise scorching on materials like wood. The fact the beam is wide means that it can be bounced around off mirrors wit out imparting too much energy to one spot, such that it burns though a mirror, or the lens.</p>
<p>&nbsp;</p>
<h1>How the laser cutter works: 102</h1>
<p><figure id="attachment_907" aria-describedby="caption-attachment-907" style="width: 229px" class="wp-caption alignright"><a href="/wp-content/uploads/2018/01/laser-cutter.jpg"><img loading="lazy" class="wp-image-907 size-medium" src="/wp-content/uploads/2018/01/laser-cutter-229x300.jpg" alt="Laser cutter beam focus" width="229" height="300" srcset="/wp-content/uploads/2018/01/laser-cutter-229x300.jpg 229w, /wp-content/uploads/2018/01/laser-cutter-780x1024.jpg 780w, /wp-content/uploads/2018/01/laser-cutter-768x1008.jpg 768w, /wp-content/uploads/2018/01/laser-cutter-1170x1536.jpg 1170w, /wp-content/uploads/2018/01/laser-cutter-1561x2048.jpg 1561w, /wp-content/uploads/2018/01/laser-cutter-1568x2058.jpg 1568w, /wp-content/uploads/2018/01/laser-cutter-scaled.jpg 1951w" sizes="(max-width: 229px) 100vw, 229px" /></a><figcaption id="caption-attachment-907" class="wp-caption-text">A CO2 laser produces an Infra red beam that is more intense in the centre. The beam is focused through a quartz lens.</figcaption></figure></p>
<p>Now think of a laser cut in slow motion and zoomed in massively.  The laser hits a material. The focal point is probably beneath the surface and the beam is still a bit wide (less hot).</p>
<p>The area at the surface vaporises and a little pilot hole forms. This hole is like the first domino, the material near it is now deformed. This deformed material (sub millimetre area) is like the plastic left in the sun, less robust and more sensitive to light. The cut now picks up momentum and deepens as a “pool of vaporising material eating into the ground”. The air stream is ejecting loose material and anything &#8216;molten&#8217; that was not instantly vaporised.</p>
<p>The ability to cut well is a balance of many factors, primarily the right laser strength, air flow and movement speed &#8211; for a given material at a certain thickness.</p>
<p>Relevant to later discussions with metal, is getting a good movement speed.</p>
<ul>
<li>Slow enough that the pit will work all the way through, before the beam moves on.</li>
<li>Fast enough that the material is not given too much heat (see diagram to right, not all the beam is vaporising goodness and its not all equal in strengths.
<ul>
<li>From the parts of the beam not near the focal point that are not hot enough .</li>
<li>From outer areas of the beam not as intense</li>
</ul>
</li>
<li>Different lenses will help with thicker materials, butt you first limitation is you will need more power for thicker materials. Otherwise you will need to move at a slow speed that brings many other problems of heat dissipation.</li>
</ul>
<p>Reading the above may lead you to think you will need to get the most powerful laser cutter you can afford, for those times when you want to do a thick material. But&#8230; power is a two edged sword. The laser will only fire at a minimum of say 40%. So your 120W laser that will get you through 20mm acrylic, won’t be any good for etching designs on clothing (it will punch straight through at it minimum of 48W).</p>
<h1>Problems that will affect metal</h1>
<ul>
<li>Many metals are reflective of IR beams (C02 lasers), preventing even etching of the surface.
<ul>
<li>NB: other lasers, such as solid state lasers which work with a different wavelength will be several times more efficient than C02 lasers for most metals.</li>
</ul>
</li>
<li>Metal is a heat sink, it will draw heat away from the cut. Preventing the laser beam from melting any of the metal, or forming the initial pit.</li>
<li>Many metals are not cool/safe in gaseous form. You may need venting.</li>
</ul>
<h2>Etching metal</h2>
<p>Your enemy for etching, is not the heat conductivity of the metal, it’s the fact it reflects.<br />
On cutters around your size it is often possible to etch certain metal. You will need to paint the surface with something (there are products that are sold for this purpose, but some people just use black $3 fiddly bit paint from buntings). The pit will form in the paint and you will get sufficient heat in to mark the metal. But then go no further down.</p>
<p>&nbsp;</p>
<h2>Cutting metal</h2>
<p>Generally laser cut metal is not ablated/vaporised (turned to gas) like other materials. It is instead it is melted (turned to liquid), and blown out of the way by forced airflow. This is sometimes referred to as ‘melt and blow’ cutting. It is messy and provides issues that can damage a machine:</p>
<ul>
<li>Bits of molten metal can settle on the lens, this will absorb heat that the lens would otherwise transmit. The lens will now heat up and be damaged / burnt though.</li>
<li>The metal / molten metal can reflect focused beam of light back at the lens. This can damage the lens, because the amount of IR radiation passing though it is now double.
<ul>
<li>The focused light can even propagate back along the mirrors and into the laser tube (damaging the very expensive parts of the machine).</li>
</ul>
</li>
</ul>
<p>Its worth mentioning that metal needs a lot more power to get the piloting pit going. And the pit is not a nice vaporised area with laser friendly material next to it. It’s a stubborn pool of liquid that sits in the way of your laser. This means cutting requires bigger lasers, or one or more assisting technologies to reduce the necessitated “bigness” of your laser.</p>
<p>Such assisting technologies, for CO2 lasers, may include.</p>
<ul>
<li>High pressure gas, to blow the molten metal out of the hole.</li>
<li>Blowing Oxygen or Nitrogen into the cut to make things more efficient.</li>
<li>Using a more focused beam to get the metal to melt before heat dissipation sets in.</li>
<li>A lens that moves, so that the focal point travels with your pit as it goes down.</li>
</ul>
<h1>As some lasers can be coerced into cutting metal, why is it not more common?</h1>
<p>Firstly, the risk to the machine means many operators don&#8217;t feel it is worth it.</p>
<p>But there are other issues:</p>
<ul>
<li>Solid state lasers are becoming more popular for cutting metal over the use of a large C02 Laser.</li>
<li>The cut speed of lasers on metal can be slow, and the depth of cut limited.</li>
<li>Tuning air/ laser/ lens /speed parameters is more difficult, and the results are not always a clean cut for inexperienced operators.</li>
</ul>
<p>But more importantly there are many <span style="text-decoration: underline;">more attractive  alternatives</span> for cutting of metal, including water jet cutting and CNC milling.</p>
<p>&nbsp;</p>
<h1>Further reading:</h1>
<p>For clarity I simplified and glossed over some less important concepts in the above explanation.</p>
<p>The following industry articles explore things in more depth:</p>
<ul>
<li>Laser comparison – cutting speed and rate of feed. <a href="http://jmtusa.com/laser-comparison-cutting-speed-and-rate-of-feed/">http://jmtusa.com/laser-comparison-cutting-speed-and-rate-of-feed/</a></li>
<li>Lasing reflective metals <a href="http://www.fsmdirect.com/cutting/laser-cutting/326-lasing-reflective-metals">http://www.fsmdirect.com/cutting/laser-cutting/326-lasing-reflective-metals</a></li>
<li>Back to basics: The subtle science of burr-free laser cutting. <a href="https://www.thefabricator.com/article/lasercutting/back-to-basics-the-subtle-science-of-burr-free-laser-cutting">https://www.thefabricator.com/article/lasercutting/back-to-basics-the-subtle-science-of-burr-free-laser-cutting</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Random Thoughts</title>
		<link>/random-thoughts/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Tue, 11 Jul 2017 11:26:39 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ideas]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=857</guid>

					<description><![CDATA[Here are some random ideas, like: "Could we get street lights to start flashing 30 seconds before an ambulance is due to come through?"]]></description>
										<content:encoded><![CDATA[<h2></h2>
<h2>Could we get street lights to start flashing 30 seconds before an ambulance is due to come through?</h2>
<p>All traffic would have time to organise itself into one lane and emergency vehicles could proceed without obstruction. This seems easy to achieve using existing</p>
<p><a href="/wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood.jpg"><img loading="lazy" class="aligncenter wp-image-858 " src="/wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-300x225.jpg" alt="" width="411" height="308" srcset="/wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-300x225.jpg 300w, /wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-1024x768.jpg 1024w, /wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-768x576.jpg 768w, /wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-1536x1152.jpg 1536w, /wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-2048x1536.jpg 2048w, /wp-content/uploads/2017/07/Northbound_freeway_traffic_greenwood-1568x1176.jpg 1568w" sizes="(max-width: 411px) 100vw, 411px" /></a></p>
<p>&nbsp;</p>
<h2>Compiler errors should link through to concise explanations or solutions on  stackoverflow, or some error code explanation wiki.</h2>
<p>Lats face it, this will speed up things a bit; especially when learning a new language.</p>
<p>&nbsp;</p>
<h2>Give random rich/powerfull people weird handshakes. See if you can pass for Illuminati.</h2>
<div class="_1dwg _1w_m">
<div>
<div id="js_89t" class="_5pbx userContent" data-ft="{&quot;tn&quot;:&quot;K&quot;}">
<p>It&#8217;s like going to go around to everyone you meet saying, &#8220;Hey, your&#8217;e from the future as well&#8230; right.&#8221;. Hopefully someone will reply &#8220;How did you know?&#8221;.</p>
<p>&nbsp;</p>
</div>
<h2 class="_3x-2">Browsers should use a 2 Mb cap in loading of any website.</h2>
<p class="_3x-2">If displaying the site goes over you get &#8220;You have visited some stupidly large web page, do you wan&#8217;t to continue?&#8221;.</p>
<div>Also why can&#8217;t there be 100 odd &#8216;standard internet fonts&#8217;, so that we can do away with many custom font downloads for web pages.</div>
<h2></h2>
<div>
<div class="_1dwg _1w_m">
<div>
<div id="js_9me" class="_5pbx userContent" data-ft="{&quot;tn&quot;:&quot;K&quot;}">
<h2>Leave fake logins on sticky notes around the office, and log if anyone attempts to use them.</h2>
<p>Also some easy to find network ports that connect to an isolated honey pot.</p>
<p>&nbsp;</p>
</div>
<div class="_3x-2"></div>
<div></div>
</div>
</div>
<div></div>
</div>
</div>
</div>
<div></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino Graphing Libraries</title>
		<link>/arduino-graphing-libraries/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Mon, 08 Feb 2016 13:58:47 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GNUPlot]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Sample Code]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=754</guid>

					<description><![CDATA[Here is a library to write GNUPlot output from the Arduino. Now the Arduino can produce a graph output that is directly renderable across multiple platforms and cloud services. Does not rely on some gone tomorrow software + lets you edit the plot afterward.]]></description>
										<content:encoded><![CDATA[<h1>Introduction</h1>
<p style="padding-left: 30px;">I believe strongly in plotting the data that I obtain, because plots tell you a story and they don&#8217;t mislead you like summary statistics can.</p>
<p style="padding-left: 30px;">Often I want to plot data the arduino has acquired, but I find existing solutions don&#8217;t suit my needs. So I went out and made my own solution which writes a GNUPlot script in response to plot commands. I integrated the library with my general Arduino Toolbox (WDArduinoLib) and am releasing it under the GNU 2.0 License.</p>
<h1>Goals</h1>
<ul>
<li>Professional graphics</li>
<li>Graphs manually editable after plotting for change colours etc.</li>
<li>Arduino outputs data that  other people can defiantly grab and use (just paste into a cloud based GNUPlot terminal)</li>
<li>Allow embedded linux system to offload the plotting of graphs from arduino collected data</li>
<li>Easy straight forward API</li>
<li>Linux, Windows and Mac compatible.</li>
<li>Quality API documentation</li>
</ul>
<h1>Features</h1>
<ul>
<li>Configurable output
<ul>
<li>You can use a Serial Port, SD-Card,  Telnet, TCP-IP, IrDA, whatever. So long as it derives from the Arduino Print class (ie has Print and Println()) this library can output a graph to it</li>
</ul>
</li>
<li>Uses <a href="http://www.gnuplot.info/" target="_blank" rel="noopener">GNUPlot</a> as a server to execute the plot script this API outputs.
<ul>
<li>GNUPlot is the standard for scientific publication, it outputs presentable graphics ready for both websites, and software manuals.</li>
<li>GNUPlot has been around forever (1986) and is still actively developed.</li>
<li>GNUPlot can run on the Raspberry pi, PC, Mac or even online via <a href="http://plotshare.com/" target="_blank" rel="noopener">http://plotshare.com/</a></li>
</ul>
</li>
<li>Extensible
<ul>
<li>Easily over-rideable classes to add new plot types or different output terminal (eg Matlab)</li>
</ul>
</li>
<li>Built in quality colour palettes designed for graphing.
<ul>
<li>Sample palettes for showing importance, of keeping different coloured categories at the same intensity.</li>
<li>Spectral palettes , optimised for on-white graphing.</li>
<li>Colour-blind compatible palettes .</li>
<li>Can still use arbitrary 24bit RGB colours if you like.</li>
</ul>
</li>
<li>Unit tested library to support quality software development</li>
<li>Template driven code designed for maximum data flexibility</li>
<li>Memory Efficient.
<ul>
<li>Use of progmem strings supported throughout.</li>
</ul>
</li>
<li>Useful, stable data format that does not rely on someone&#8217;s pet project still existing in 5 years time.</li>
<li>All input, including text, is validated.</li>
</ul>
<p>&nbsp;</p>
<h1>Examples</h1>
<p style="padding-left: 30px;">This library is simple to use and produces clean results with minimal configuration. I present several basic examples that show the API in use and the results obtained.</p>
<hr />
<h2>Example: Basic Line Graph</h2>
<p style="padding-left: 30px;">Line plots of time series data are probably the most important feature any graphing API targeted for micro-controllers can offer. This code creates such a plot. It demonstrates the use of multiple line styles.</p>
<pre class="height-set:true height:800 lang:c++ decode:true">//main
GNUPlotLineGraph gnuLinePlotter(&amp;Serial);
PlotDampenedSineWaves(gnuLinePlotter);

//method
void PlotDampenedSineWaves(SerialGraph&amp; plot)
{
	//setup graph
	plot.newGraph();
	plot.enableSaveImageFile(true);
	plot.setTitle(F("Dampened Sine Wave"));
	plot.setXAxisName(F("Time (Sec)"));
	plot.setYAxisName(F("Voltage (V)"));

	//setup series
	plot.setSeriesName(0, F("Slow decay"));
	plot.getLineApperance(0)-&gt;setLineStyle(LineStyles::SolidLine);
	plot.getLineApperance(0)-&gt;setLineWidth(4);
	plot.getLineApperance(0)-&gt;setRGB(GraphColorsSchemeBlues::Blue1);


	plot.setSeriesName(1, F("Medium decay"));
	plot.getLineApperance(1)-&gt;setLineStyle(LineStyles::DashedLine);
	plot.getLineApperance(1)-&gt;setLineWidth(3);
	plot.getLineApperance(1)-&gt;setRGB(GraphColorsSchemeBlues::Blue2);

	plot.setSeriesName(2, F("Quick decay"));
	plot.getLineApperance(2)-&gt;setLineStyle(LineStyles::DotedLine);
	plot.getLineApperance(2)-&gt;setLineWidth(2);
	plot.getLineApperance(2)-&gt;setRGB(GraphColorsSchemeBlues::Blue3);
	
        //plot graph
	for(int i=0; i&lt;=720; i+=3)
	{
		float c = cos(DEG_TO_RAD*(float)i); 
		float y1 = Dampen(i, c, 1, 1.0/360.0); 
		float y2 = Dampen(i, c, 1, 1.0/240.0); 
		float y3 = Dampen(i, c, 1, 1.0/180.0); 

		plot.plotDatumXYn(i, y1, y2, y3);
	}
	plot.finishGraph();
}

</pre>
<p><a href="/wp-content/uploads/2015/12/Damped-Sine-Wave.png" rel="attachment wp-att-757"><img loading="lazy" class="size-full wp-image-757 aligncenter" src="/wp-content/uploads/2015/12/Damped-Sine-Wave.png" alt="Damped Sine Wave" width="800" height="600" srcset="/wp-content/uploads/2015/12/Damped-Sine-Wave.png 800w, /wp-content/uploads/2015/12/Damped-Sine-Wave-300x225.png 300w, /wp-content/uploads/2015/12/Damped-Sine-Wave-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></a></p>
<p>&nbsp;</p>
<hr />
<h2>Example: Plotting Points (Scatter Plot)</h2>
<p style="padding-left: 30px;">A scatter plots, with styles colours and trimmings.</p>
<pre class="height-set:true lang:c++ decode:true">//main
GNUPlotPointGraph gnuPointPlotter(&amp;Serial);
PlotPointNoise(gnuPointPlotter);

//method
void PlotPointNoise(SerialGraph&amp; plot)
{
	//setup graph
	plot.newGraph();
	plot.enableSaveImageFile(true);
	plot.setTitle(F("Sine Waves with Noise"));
	plot.setXAxisName(F("Time (Sec)"));
	plot.setYAxisName(F("Voltage (V)"));
	plot.setShowGrid(true);

	//setup series
	plot.setSeriesName(0, F("Pin 1"));
	plot.getLineApperance(0)-&gt;setMarkerStyle(LineMarkers::SquareMarker);
	plot.getLineApperance(0)-&gt;setRGB(0xff0000);

	plot.setSeriesName(1, F("Pin 2"));
	plot.getLineApperance(1)-&gt;setMarkerStyle(LineMarkers::CrossMarker);
	plot.getLineApperance(1)-&gt;setRGB(0x00ff00);

	plot.setSeriesName(2, F("Pin 3"));
	plot.getLineApperance(2)-&gt;setMarkerStyle(LineMarkers::CircleMarker);
	plot.getLineApperance(2)-&gt;setRGB(0x0000ff);
	
        //plot graph
	for(int i=0; i&lt;=720; i+=5)
	{
		float c = cos(DEG_TO_RAD*(float)i); 
		float y1 = c + Dampen(i, ((float)(random(100)-50)) *0.1, 1, 1.0/240.0); 
		float y2 = c + Dampen(i, ((float)(random(100)-50)) *0.1, 1, 1.0/180.0)-2; 
		float y3 = c + Dampen(i, ((float)(random(100)-50)) *0.1, 1, 1.0/90.0)-4; 

		plot.plotDatumXYn(i, y1, y2, y3);
	}
	plot.finishGraph();
}

</pre>
<p><a href="/wp-content/uploads/2015/12/Sine-Wave-with-Noise.png" rel="attachment wp-att-755"><img loading="lazy" class="size-full wp-image-755 aligncenter" src="/wp-content/uploads/2015/12/Sine-Wave-with-Noise.png" alt="Sine Wave with Noise" width="800" height="600" srcset="/wp-content/uploads/2015/12/Sine-Wave-with-Noise.png 800w, /wp-content/uploads/2015/12/Sine-Wave-with-Noise-300x225.png 300w, /wp-content/uploads/2015/12/Sine-Wave-with-Noise-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></a></p>
<p>&nbsp;</p>
<hr />
<h2>Example: Plotting Arbitrary Lines</h2>
<p style="padding-left: 30px;">Sometimes your not using time series data, and need to plot lines between arbitrary x/y positions. Many solutions for the arduino breakdown at this point. Here I demonstrate such a plot (based on the logarithmic spiral). Note I am using lines with point markers to show the actual points plotted.</p>
<pre class="height-set:true lang:c++ decode:true">//main
GNUPlotLineGraph gnuLinePlotter(&amp;Serial);
PlotLogarithmicSpiral(gnuLinePlotter);

//method
void PlotLogarithmicSpiral(SerialGraph&amp; plot)
{
	//setup graph
	plot.newGraph();
	plot.enableSaveImageFile(true);
	plot.setTitle(F("Logarithmic Spiral"));

	//setup series
	plot.setSeriesName(0, F("Spiral"));
	plot.getLineApperance(0)-&gt;setLineWidth(2);
	plot.getLineApperance(0)-&gt;setMarkerStyle(LineMarkers::SolidCircleMarker);
	plot.getLineApperance(0)-&gt;setRGB(GraphColorsSchemeSpectral::Spectral7);
		
	//plot graph
	float a = 1;
	float b = 0.1759;
	for(int i=0; i&lt;(int)(10.0*20.0*M_PI); i+=5)
	{
		float t = ((float)i) * 0.1;
		float rt = a*pow(M_E, b* t);
		float x = rt*cos(t);
		float y = rt*sin(t);

		plot.plotDatumXY(x, y);
	}

	plot.finishGraph();
}</pre>
<p style="padding-left: 30px;"><a href="/wp-content/uploads/2015/12/Logarithmic-Spiral.png" rel="attachment wp-att-761"><img loading="lazy" class="size-full wp-image-761 aligncenter" src="/wp-content/uploads/2015/12/Logarithmic-Spiral.png" alt="Logarithmic Spiral" width="800" height="600" srcset="/wp-content/uploads/2015/12/Logarithmic-Spiral.png 800w, /wp-content/uploads/2015/12/Logarithmic-Spiral-300x225.png 300w, /wp-content/uploads/2015/12/Logarithmic-Spiral-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></a></p>
<hr />
<h2>Example: Multi Column Bar Graph.</h2>
<p style="padding-left: 30px;">Bar graphs, for histograms and such are easy in this API. The example below shows support for multi column graphs, Note: negative values are also supported. The labels for the X-Axis are plotted as standard x values (the plot command is template driven and can support many different types of data).</p>
<pre class="height-set:true lang:c++ decode:true">//main
GNUPlotBarGraph gnuBarPlotter(&amp;Serial);
PlotSampleBarGraph(gnuBarPlotter);

//method
void PlotSampleBarGraph(SerialGraph&amp; plot)
{
	//setup graph
	plot.newGraph();
	plot.enableSaveImageFile(true);
	plot.setTitle(F("Google Results for Instruments"));
	plot.setXAxisName(F("Instrument"));
	plot.setYAxisName(F("# Google Results (millions)"));
	plot.setShowGrid(true);

	//setup series
	plot.setSeriesName(0, F("play"));
	plot.getLineApperance(0)-&gt;setRGB(GraphColorsSchemeOranges::Orange1);
	plot.setSeriesName(1, F("teach"));
	plot.getLineApperance(1)-&gt;setRGB(GraphColorsSchemeBlues::Blue1);
	plot.setSeriesName(2, F("like"));
	plot.getLineApperance(2)-&gt;setRGB(GraphColorsSchemeGreens::Green1);
	plot.setSeriesName(3, F("hate"));
	plot.getLineApperance(3)-&gt;setRGB(GraphColorsSchemeReds::Red1);

	//plot graph
	//Dataset compiled by Google-ing "I X the Y"
	//                instrument	play	teach	like	hate
	plot.plotDatumXYn("Piano",		173,	25,		211,	21);
	plot.plotDatumXYn("Guitar",		163,	22,		193,	27);
	plot.plotDatumXYn("Violin",     41,		2,		43,		1);
	plot.plotDatumXYn("Drums",		30,		8,		83,		9);
	
	plot.finishGraph();
}</pre>
<p style="padding-left: 30px;"><a href="/wp-content/uploads/2015/12/Google-Results-for-Instruments.png" rel="attachment wp-att-762"><img loading="lazy" class="size-full wp-image-762 aligncenter" src="/wp-content/uploads/2015/12/Google-Results-for-Instruments.png" alt="Google Results for Instruments" width="800" height="600" srcset="/wp-content/uploads/2015/12/Google-Results-for-Instruments.png 800w, /wp-content/uploads/2015/12/Google-Results-for-Instruments-300x225.png 300w, /wp-content/uploads/2015/12/Google-Results-for-Instruments-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></a></p>
<h1>Installation</h1>
<p>&nbsp;</p>
<ol>
<li>Get the library from its <a href="https://github.com/busyDuckman/WDArduinoLib" target="_blank" rel="noopener">github repository</a>.</li>
<li>See the official guide on how to install libraries <a href="https://www.arduino.cc/en/Guide/Libraries" target="_blank" rel="noopener">https://www.arduino.cc/en/Guide/Libraries</a></li>
<li>Run the provided example sketch</li>
<li>Install GNUPlot v5.0 or later (<a href="http://www.gnuplot.info/download.html" target="_blank" rel="noopener">here</a>).</li>
<li>Using the com port viewer, copy the output of sketch into GNUPlot.</li>
<li>Enjoy!</li>
</ol>
<p>It is very possible to get the output generated by this library to GNUPlot automatically. How you achieve this is up to you.</p>
<p>It is possible to direct the output to a SD card. See the arduino help page on the <a href="https://www.arduino.cc/en/Tutorial/Files" target="_blank" rel="noopener">file class</a>, to create you own file on a SD card. Then pass the open file object in to the constructor for your plotting class (where I used Serial in the examples).</p>
<h1></h1>
<h1>Documentation</h1>
<p style="padding-left: 30px;">Full documentation available <a href="http://www.busyducks.com/downloads/doco/WDArduinoLib/index.html" target="_blank" rel="noopener">here</a>.</p>
<p>&nbsp;</p>
<h1>License</h1>
<p style="padding-left: 30px;">GNU 2.0</p>
<h1>State</h1>
<p>Most Features are well tested, but I don&#8217;t warrant or accept liability for any of the functionality in any way.</p>
<p>NB: some dynamic memory usage , refrain from using malloc during plotting operations to prevent possible heap fragmentation.</p>
<ul>
<li>Dynamic memory usage is a design decision I made weighing pro&#8217;s and con&#8217;s of the situation.</li>
<li>Given &#8216;typical usage&#8217; scenarios of the API it should not cause heap fragmentation.</li>
</ul>
<p>&nbsp;</p>
<h1>Road-Map</h1>
<p>May happen:</p>
<ul>
<li>Second x/y axis support</li>
<li>Matlab support</li>
<li>3d plots</li>
<li>Spectrogram</li>
<li>Support for cloud based rendering for graphs</li>
<li>Sage support</li>
<li>Thousands separator (right now I could not deploy it because of a bug in the windows version of GNUPlot).</li>
</ul>
<p>Won&#8217;t Happen:</p>
<ul>
<li>Real-time visualisation (plenty of other projects to do that already)</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ASCII-Art Arduino Pinouts</title>
		<link>/ascii-art-arduino-pinouts/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Mon, 16 Nov 2015 18:09:31 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Edcucational]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=704</guid>

					<description><![CDATA[Managing arduino projects can be a nightmare because its hard to keep track of your hardware setup in your code comments.  To enable easy documentation of pin assignments, I created a couple of ASCII art arduino pin-outs.

These come complete with ports, PWM and coms all marked. Simply paste as a comment into your code and marvel at your new found organisation.]]></description>
										<content:encoded><![CDATA[<h1>Introduction</h1>
<p style="padding-left: 30px;">Managing arduino projects can be a nightmare because you only see the software side in your code documentation, the hardware is hard to keep track off.</p>
<p style="padding-left: 30px;">To enable easy documentation of pin assignments, I created a couple of ASCII art arduinos; complete with ports, PWM and coms all marked. Simply paste as a comment into your code and marvel at your new found organisation.</p>
<p style="padding-left: 30px;">I suggest altering the image (eg. a letter or X in the [ ]) to keep track of the pins you ended up using.</p>
<p style="padding-left: 30px;">Find this project on <a href="https://github.com/busyDuckman/ascii-art-arduinos">gitHub</a></p>
<h1>Plain Text &#8211; Arduino Pinout</h1>
<p style="padding-left: 30px;">Here is copy/paste-able Arduino Pinout ASCII art ready to go (tip: you can use the copy button, at the top of each ASCII art piece, to make the process easy).<br />
<em>     <span style="color: #999999;">I place them in the Creatice Commons [Creative Commons Attribution (BY) license]. </span></em><br />
<span style="color: #999999;"><em>     Attribution via the url: &#8220;http://busyducks.com/ascii-art-arduinos&#8221;</em></span></p>
<pre class="lang:c++ decode:true">                                      +-----+
         +----[PWR]-------------------| USB |--+
         |                            +-----+  |
         |         GND/RST2  [ ][ ]            |
         |       MOSI2/SCK2  [ ][ ]  A5/SCL[ ] |   C5 
         |          5V/MISO2 [ ][ ]  A4/SDA[ ] |   C4 
         |                             AREF[ ] |
         |                              GND[ ] |
         | [ ]N/C                    SCK/13[ ] |   B5
         | [ ]IOREF                 MISO/12[ ] |   .
         | [ ]RST                   MOSI/11[ ]~|   .
         | [ ]3V3    +---+               10[ ]~|   .
         | [ ]5v    -| A |-               9[ ]~|   .
         | [ ]GND   -| R |-               8[ ] |   B0
         | [ ]GND   -| D |-                    |
         | [ ]Vin   -| U |-               7[ ] |   D7
         |          -| I |-               6[ ]~|   .
         | [ ]A0    -| N |-               5[ ]~|   .
         | [ ]A1    -| O |-               4[ ] |   .
         | [ ]A2     +---+           INT1/3[ ]~|   .
         | [ ]A3                     INT0/2[ ] |   .
         | [ ]A4/SDA  RST SCK MISO     TX&gt;1[ ] |   .
         | [ ]A5/SCL  [ ] [ ] [ ]      RX&lt;0[ ] |   D0
         |            [ ] [ ] [ ]              |
         |  UNO_R3    GND MOSI 5V  ____________/
          \_______________________/
		  
		  http://busyducks.com/ascii-art-arduinos</pre>
<pre class="lang:c++ decode:true ">                                      +-----+
         +----[PWR]-------------------| USB |--+
         |                            +-----+  |
         |           GND/RST2  [ ] [ ]         |
         |         MOSI2/SCK2  [ ] [ ]  SCL[ ] |   D0
         |            5V/MISO2 [ ] [ ]  SDA[ ] |   D1
         |                             AREF[ ] |
         |                              GND[ ] |
         | [ ]N/C                        13[ ]~|   B7
         | [ ]IOREF                      12[ ]~|   B6
         | [ ]RST                        11[ ]~|   B5
         | [ ]3V3      +----------+      10[ ]~|   B4
         | [ ]5v       | ARDUINO  |       9[ ]~|   H6
         | [ ]GND      |   MEGA   |       8[ ]~|   H5
         | [ ]GND      +----------+            |
         | [ ]Vin                         7[ ]~|   H4
         |                                6[ ]~|   H3
         | [ ]A0                          5[ ]~|   E3
         | [ ]A1                          4[ ]~|   G5
         | [ ]A2                     INT5/3[ ]~|   E5
         | [ ]A3                     INT4/2[ ]~|   E4
         | [ ]A4                       TX&gt;1[ ]~|   E1
         | [ ]A5                       RX&lt;0[ ]~|   E0
         | [ ]A6                               |   
         | [ ]A7                     TX3/14[ ] |   J1
         |                           RX3/15[ ] |   J0
         | [ ]A8                     TX2/16[ ] |   H1         
         | [ ]A9                     RX2/17[ ] |   H0
         | [ ]A10               TX1/INT3/18[ ] |   D3         
         | [ ]A11               RX1/INT2/19[ ] |   D2
         | [ ]A12           I2C-SDA/INT1/20[ ] |   D1         
         | [ ]A13           I2C-SCL/INT0/21[ ] |   D0
         | [ ]A14                              |            
         | [ ]A15                              |   Ports:
         |                RST SCK MISO         |    22=A0  23=A1   
         |         ICSP   [ ] [ ] [ ]          |    24=A2  25=A3   
         |                [ ] [ ] [ ]          |    26=A4  27=A5   
         |                GND MOSI 5V          |    28=A6  29=A7   
         | G                                   |    30=C7  31=C6   
         | N 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 5 |    32=C5  33=C4   
         | D 2 0 8 6 4 2 0 8 6 4 2 0 8 6 4 2 V |    34=C3  35=C2   
         |         ~ ~                         |    36=C1  37=C0   
         | @ # # # # # # # # # # # # # # # # @ |    38=D7  39=G2    
         | @ # # # # # # # # # # # # # # # # @ |    40=G1  41=G0   
         |           ~                         |    42=L7  43=L6   
         | G 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 5 |    44=L5  45=L4   
         | N 3 1 9 7 5 3 1 9 7 5 3 1 9 7 5 3 V |    46=L3  47=L2   
         | D                                   |    48=L1  49=L0    SPI:
         |                                     |    50=B3  51=B2     50=MISO 51=MOSI
         |     2560                ____________/    52=B1  53=B0     52=SCK  53=SS 
          \_______________________/         
         
         http://busyducks.com/ascii-art-arduinos</pre>
<p style="padding-left: 30px;">You may notice that the clean layout of these diagrams makes them very readable, personally I feel many graphical versions present too much information at once.</p>
<h3>Some Updates (new models)</h3>
<p style="padding-left: 30px;">This idea seems to have caught on quickly, so I will keep the art coming.</p>
<p style="padding-left: 30px;">Redit user <em>plasticluthier</em> adapted a nano version <a href="https://www.reddit.com/r/arduino/comments/3tb0d2/i_made_some_asciiart_arduinos_to_paste_in/" target="_blank" rel="noopener">here</a>, I thought that was spiffy, so I fixed an error tweaked it a bit and added chips and ports.</p>
<pre class="lang:c++ decode:true">                      +-----+
         +------------| USB |------------+
         |            +-----+            |
    B5   | [ ]D13/SCK        MISO/D12[ ] |   B4
         | [ ]3.3V           MOSI/D11[ ]~|   B3
         | [ ]V.ref     ___    SS/D10[ ]~|   B2
    C0   | [ ]A0       / N \       D9[ ]~|   B1
    C1   | [ ]A1      /  A  \      D8[ ] |   B0
    C2   | [ ]A2      \  N  /      D7[ ] |   D7
    C3   | [ ]A3       \_0_/       D6[ ]~|   D6
    C4   | [ ]A4/SDA               D5[ ]~|   D5
    C5   | [ ]A5/SCL               D4[ ] |   D4
         | [ ]A6              INT1/D3[ ]~|   D3
         | [ ]A7              INT0/D2[ ] |   D2
         | [ ]5V                  GND[ ] |     
    C6   | [ ]RST                 RST[ ] |   C6
         | [ ]GND   5V MOSI GND   TX1[ ] |   D0
         | [ ]Vin   [ ] [ ] [ ]   RX1[ ] |   D1
         |          [ ] [ ] [ ]          |
         |          MISO SCK RST         |
         | NANO-V3                       |
         +-------------------------------+
         
         http://busyducks.com/ascii-art-arduinos</pre>
<p style="padding-left: 30px;">I have a Pro Mini project coming up, so knocked one of these out as well.</p>
<pre class="lang:c++ decode:true">		                  D0   D1   RST
		   GND  GND  VCC  RX   TX   /DTR
        +--------------------------------+
        |  [ ]  [ ]  [ ]  [ ]  [ ]  [ ]  |
        |              FTDI              |
    D1  | [ ]1/TX                 RAW[ ] |    
    D0  | [ ]0/RX                 GND[ ] |    
        | [ ]RST        SCL/A5[ ] RST[ ] |   C6
        | [ ]GND        SDA/A4[ ] VCC[ ] |    
    D2  | [ ]2/INT0    ___         A3[ ] |   C3
    D3  |~[ ]3/INT1   /   \        A2[ ] |   C2
    D4  | [ ]4       /PRO  \       A1[ ] |   C1
    D5  |~[ ]5       \ MINI/       A0[ ] |   C0
    D6  |~[ ]6        \___/    SCK/13[ ] |   B5
    D7  | [ ]7          A7[ ] MISO/12[ ] |   B4
    B0  | [ ]8          A6[ ] MOSI/11[ ]~|   B3
    B1  |~[ ]9                  SS/10[ ]~|   B2
        |           [RST-BTN]            |    
        +--------------------------------+  
		
		http://busyducks.com/ascii-art-arduinos</pre>
<h1>How to use them</h1>
<p style="padding-left: 30px;">Just fill in the spaces, either with an X, or with a reference letter which you document below the ASCII art.</p>
<p style="padding-left: 30px;">They can be pasted into code comments, (use /* and */ in the arduino IDE to create a block comment). They can also be useful in forums, when you need a quick arduino diagram, but don&#8217;t want to fire up an image editor.</p>
<p><a href="/wp-content/uploads/2015/11/Arduino_UNO_pinout.png"><img loading="lazy" class="alignnone wp-image-705 size-full" src="/wp-content/uploads/2015/11/Arduino_UNO_pinout.png" alt="Arduino_UNO_pinout" width="473" height="533" srcset="/wp-content/uploads/2015/11/Arduino_UNO_pinout.png 473w, /wp-content/uploads/2015/11/Arduino_UNO_pinout-266x300.png 266w" sizes="(max-width: 473px) 100vw, 473px" /></a></p>
<p><a href="/wp-content/uploads/2015/11/Arduino_mega_pinout2.png"><img loading="lazy" class="alignnone size-full wp-image-714" src="/wp-content/uploads/2015/11/Arduino_mega_pinout2.png" alt="Arduino_mega_pinout2" width="585" height="786" srcset="/wp-content/uploads/2015/11/Arduino_mega_pinout2.png 585w, /wp-content/uploads/2015/11/Arduino_mega_pinout2-223x300.png 223w" sizes="(max-width: 585px) 100vw, 585px" /></a></p>
<p>&nbsp;</p>
<p>This is a snippet from a recent project. The sketch starts out with comments that set-out how the hardware is setup, this helps me a lot when I have to look at it again in a years time. Its also great if I want to share the code, as people don&#8217;t need to dig-around in the code to see how to connect the arduino to other devices.</p>
<pre class="height-set:true height:600 lang:c++ decode:true" title="Exaple usage in an arduino sketch">/*

                                      +-----+
         +----[PWR]-------------------| USB |--+
         |                            +-----+  |
         |           GND/RST2  [ ] [ ]         |
         |         MOSI2/SCK2  [ ] [ ]  SCL[ ] |   C5
         |            5V/MISO2 [ ] [ ]  SDA[ ] |   C4
         |                             AREF[ ] |
         |                              GND[ ] |
         | [ ]N/C                    SCK/13[A] |   B5
         | [ ]v.ref                 MISO/12[A] |   .
         | [ ]RST                   MOSI/11[A]~|   .
         | [ ]3V3    +---+               10[ ]~|   .
         | [ ]5v     | A |                9[ ]~|   .
         | [ ]GND   -| R |-               8[B] |   B0
         | [ ]GND   -| D |-                    |
         | [ ]Vin   -| U |-               7[A] |   D7
         |          -| I |-               6[A]~|   .
         | [ ]A0    -| N |-               5[C]~|   .
         | [ ]A1    -| O |-               4[A] |   .
         | [ ]A2     +---+           INT1/3[A]~|   .
         | [ ]A3                     INT0/2[ ] |   .
         | [ ]A4      RST SCK MISO     TX&gt;1[ ] |   .
         | [ ]A5      [ ] [ ] [ ]      RX&lt;0[ ] |   D0
         |            [ ] [ ] [ ]              |
         |  UNO_R3    GND MOSI 5V  ____________/
          \_______________________/
		  
		  http://busyducks.com/ascii-art-arduinos
*/

//------------------------------------------------------------------ 
// [A]		Adafruit music shield
//------------------------------------------------------------------ 
// Connect CLK, MISO and MOSI to hardware SPI pins. 
// SPI Clock, shared with SD card
#define CLK_PIN (13)       
// Input data, from VS1053/SD card
#define MISO_PIN (12)      
// Output data, to VS1053/SD card
#define MOSI_PIN (11)      

// VS1053 reset pin (unused!)
#define SHIELD_RESET_PIN  (-1)   
// VS1053 chip select pin (output)
#define SHIELD_CS_PIN     (7)      
// VS1053 Data/command select pin (output)
#define SHIELD_DCS_PIN    (6)      
// Card chip select pin
#define CARDCS_PIN (4)     
// VS1053 Data request, ideally an Interrupt pin
#define DREQ_PIN (3)       

//------------------------------------------------------------------  
// [B]		WS2811 LED stip
//------------------------------------------------------------------ 
#define LED_STIP_PIN  (8)

//------------------------------------------------------------------  
// [C]		Servo Motor
//------------------------------------------------------------------ 
#define SERVO_PIN (5)</pre>
<p>&nbsp;</p>
<h1>Related Projects (based on this work)</h1>
<ul>
<li>I modified a version of this for <a href="http://casual-effects.com/markdeep/" target="_blank" rel="noopener">markdeep</a> and made it available for download  <a href="http://busyducks.com/downloads/random_blog_stuff/ascii_art_arduino_markdeep.zip" target="_blank" rel="noopener">here</a>.
<ul>
<li>There is a unofficial mirror (by <a class="author may-blank id-t2_6hpwy" href="https://www.reddit.com/user/vanderZwan">vanderZwan</a>) of the markdeep work <a href="http://blindedcyclops.neocities.org/asciiino/arduino.md.html" target="_blank" rel="noopener">here</a></li>
</ul>
</li>
<li>A console version, by paulfantom, for terminal users is available <a href="https://github.com/paulfantom/Arduino-colors" target="_blank" rel="noopener">here</a>.</li>
</ul>
<p style="padding-left: 30px;"><a href="http://busyducks.com/downloads/random_blog_stuff/ascii_art_arduino_markdeep.zip"><img loading="lazy" class="alignnone wp-image-731 size-full" src="/wp-content/uploads/2015/11/md-ascii-arduino.png" alt="md-ascii-arduino" width="411" height="492" srcset="/wp-content/uploads/2015/11/md-ascii-arduino.png 411w, /wp-content/uploads/2015/11/md-ascii-arduino-251x300.png 251w" sizes="(max-width: 411px) 100vw, 411px" /></a></p>
<p style="padding-left: 90px;"><strong>Our markdeep version (click image to download)</strong></p>
<p>&nbsp;</p>
<h2>Stay Up To date and Provide Feedback</h2>
<ul>
<li>Contribute  to the project on <a href="https://github.com/busyDuckman/ascii-art-arduinos">https://github.com/busyDuckman/ascii-art-arduinos</a></li>
<li>I will check back on the facebook page for any comments, like the page to stay up to date.
<ul>
<li><a href="https://www.facebook.com/BusyDucks/" target="_blank" rel="noopener">https://www.facebook.com/BusyDucks/</a></li>
</ul>
</li>
<li>I set up a redirected URL <a href="http://busyducks.com/ascii-art-arduinos" target="_blank" rel="noopener">http://busyducks.com/ascii-art-arduinos</a>  that is both the CC-BY attribution line, and will always redirect to the latest version of these ascii art arduinos.</li>
</ul>
<p>&nbsp;</p>
<h1>Version History</h1>
<ul>
<li>18-11-2015   markdeep version added (as suggested by vanderZwan <a href="https://www.reddit.com/r/arduino/comments/3tb0d2/i_made_some_asciiart_arduinos_to_paste_in/" target="_blank" rel="noopener">here</a>)</li>
<li>19-11-2015   typos fixed (as noted by oroki <a href="https://www.reddit.com/r/arduino/comments/3tb0d2/i_made_some_asciiart_arduinos_to_paste_in/" target="_blank" rel="noopener">here</a>)</li>
<li>21-112015    Added nano (derived from <em>plasticluthier&#8217;s contributions</em> ) &amp;  Pro Mini</li>
<li>1-12-2015     Fixed typo&#8217;s spotted by Basile Laderchi. Also minor visual tweak to the arduino CPU.</li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>RGB Bias Lighting with Arduino (Part 1)</title>
		<link>/rgb-bias-lighting-with-arduino-part-1/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Mon, 09 Nov 2015 17:55:35 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[WS2811]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=679</guid>

					<description><![CDATA[We are setting up an arduino with a WS2811 LED strip to do RGB based bias lighting effects.]]></description>
										<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Bias Lighting is a light around your display that helps you perceive contrast and reduces eye stress. It also just looks just plain cool, and create a kind of relaxed vibe.</p>
<p>There is a lot of theory on optimising bias lighting, but really any light will help quite a bit. So why not see if we can do anything inventive with the bias lighting colour.</p>
<h1>The Idea</h1>
<p>Lets use a bias lighting that changes colour, and experiment with:</p>
<ul>
<li>Altering the colour to  correspond with the time of a day</li>
<li>Blink light to warn you that you have a meeting soon</li>
<li>Having the colour change match the movement of the sun</li>
<li>Changing the colour to green (or whatever) when its your &#8220;bed time&#8221;</li>
<li>Using a colour change scheme set to work with your circadian rhythm</li>
</ul>
<p>&nbsp;</p>
<h1>Materials</h1>
<p>What you will need:</p>
<ul>
<li>Some WS2811 LED strips (approx 30cm per monitor)</li>
<li>An arduino</li>
<li>Some 3 core wire</li>
<li>About an hour free time</li>
<li>Electrical tape</li>
</ul>
<p>&nbsp;</p>
<h1>Results</h1>
<p>&nbsp;</p>
<p><iframe loading="lazy" title="RGB Bias lighting on three monitors (using an arduino)." width="940" height="529" src="https://www.youtube.com/embed/_tsl4WFH_8o?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p>&nbsp;</p>
<h1>WS2811 RGB Strips</h1>
<p>WS2811 strips can be acquired via <a href="http://www.aliexpress.com/w/wholesale-ws2811-led-strip.html" target="_blank" rel="noopener">Ali Express</a> at a reasonable price, they are a strip of RGB LED&#8217;s that are individually addressable (set any LED to any colour).</p>
<p>Pros&#8217;</p>
<ul>
<li>Each chip has an active data repeater that forwards the data signal. Provided the 5v power to the strip is strong, the data signal is propagated to as many chips as you like.</li>
<li>Very good value</li>
<li>Strong bright lights</li>
<li>Fast data channel</li>
<li>Only requires one GPIO pin.</li>
</ul>
<p>Cons&#8217;</p>
<ul>
<li>PWM control used for arbitrary colours is not super fast. Use of 7 colours that involve any LED being either full on or gull off produces results that work better for moving items / camera.</li>
<li>Poor build quality occasionally causes minor issues</li>
<li>Some visual artefacts from &#8220;fast moving pixels&#8221;.  (that can look very cool if used correctly).</li>
</ul>
<p>The strips look like what you see below. They can be cut to length, and have a soldered connection every 30cm or so.  The arrows indicate the direction the data signal is propagated in, your controller (eg an arduino) must be connected to the left most (first) arrow. However the voltage to run the strip can be applied anywhere.</p>
<p><a href="/wp-content/uploads/2015/11/WS2811_strip.jpg" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-694 size-large" src="/wp-content/uploads/2015/11/WS2811_strip-1024x193.jpg" alt="WS2811_strip" width="640" height="121" srcset="/wp-content/uploads/2015/11/WS2811_strip-1024x193.jpg 1024w, /wp-content/uploads/2015/11/WS2811_strip-300x57.jpg 300w, /wp-content/uploads/2015/11/WS2811_strip-768x145.jpg 768w, /wp-content/uploads/2015/11/WS2811_strip-1536x290.jpg 1536w, /wp-content/uploads/2015/11/WS2811_strip-2048x386.jpg 2048w, /wp-content/uploads/2015/11/WS2811_strip-1568x296.jpg 1568w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>A close up look shows a chip (black part on the left) and three LED&#8217;s, the middle one being red.</p>
<p style="padding-left: 90px;"><a href="/wp-content/uploads/2015/11/WS2811_single2.jpg" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-696 size-medium" src="/wp-content/uploads/2015/11/WS2811_single2-300x226.jpg" alt="WS2811_single2" width="300" height="226" srcset="/wp-content/uploads/2015/11/WS2811_single2-300x226.jpg 300w, /wp-content/uploads/2015/11/WS2811_single2-1024x770.jpg 1024w, /wp-content/uploads/2015/11/WS2811_single2-768x578.jpg 768w, /wp-content/uploads/2015/11/WS2811_single2.jpg 1391w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>&nbsp;</p>
<h1>Arduino Setup</h1>
<p>For effective bias lighting, stick an adhesive LED strip to the back of your monitor, about 5cm from the top. The arduino can be mounted with stick on velcro to what have you. If necessary, connect up multiple sections of LED strips (one for each monitor) using a good 3 core wire.</p>
<p>The LED strip&#8217;s data line is connected to a single arduino GPIO pin configured as an output.  Its important to note the <span style="text-decoration: underline;">strip has an arrow on it</span>, this arrow shows the direction the data will travel. Your data cable must be connected to the first  LED in the strip (not the last).</p>
<p>For my three monitors I was able to power the strip directly from my arduino, using only USB power. Though your mileage may vary.</p>
<p><strong>Setup via USB Power</strong></p>
<p>If you can get away with it wire up the strips shown in the top diagram. Be aware that your PC or USB hub will be responsible for providing power to a large set of lights.</p>
<p>Consider some issues with this:</p>
<ul>
<li>There will remain a significant current draw on the PC even while its in sleep mode (or running of batteries).  Be aware not all PC power supplies sleep well , they may turn their fans off even though you are drawing enough current to necessitate a low amount of active cooling.</li>
<li>Your arduinos regulator will may get hot.</li>
<li>Your USB port may well not be up to task.</li>
</ul>
<p><span style="color: #000000;">For these reasons I would advise:</span></p>
<ul>
<li><span style="color: #000000;">Connection via a powered USB hub. </span></li>
<li>Use of a <a href="http://amzn.to/1Qok8qt" target="_blank" rel="noopener">USB Doctor Device</a> to check your current draw is sensible (eg 350mA or below, the 500mA max in the USB spec does not always pan out well)</li>
<li>Configuring the brightness of the LED output (programmatically) to reduce current draw.</li>
<li>Don&#8217;t connect the Arduous power jack to a DC wall adapter (see note on ground loops later in this article).</li>
</ul>
<p>&nbsp;</p>
<p><a href="/wp-content/uploads/2015/11/rgb_leds_usb.png" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-688 size-large" src="/wp-content/uploads/2015/11/rgb_leds_usb-1024x371.png" alt="rgb_leds_usb" width="640" height="232" srcset="/wp-content/uploads/2015/11/rgb_leds_usb-1024x371.png 1024w, /wp-content/uploads/2015/11/rgb_leds_usb-300x109.png 300w, /wp-content/uploads/2015/11/rgb_leds_usb-768x278.png 768w, /wp-content/uploads/2015/11/rgb_leds_usb-1536x557.png 1536w, /wp-content/uploads/2015/11/rgb_leds_usb-1568x568.png 1568w, /wp-content/uploads/2015/11/rgb_leds_usb.png 1644w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>&nbsp;</p>
<p>If your Arduino fails to start, or the strip displays a gaudy set of flashing bright colours, you will need to use external power to run the strip. The cutt-off regarding how long your strip can be, before problems appear varies greatly between different production runs (of the RGB strip, not the arduino).</p>
<p><strong>Setup via External 5V power supply</strong></p>
<p>To use an external power supply  to power the strip is not difficult (see image below). But it leaves us with the annoying issue of ground loops (see ground loop section later in this article).</p>
<p>To use external 5V power:</p>
<ul>
<li>Connect the 5V ground to both the arduinos ground and the LED strips ground.</li>
<li>Set-up a 7V(ish) power for the arduinos DC Jack, and use a cheap buck DC-DC power supply (eg <a href="http://amzn.to/1NlT1ac" target="_blank" rel="noopener">LM2596 module</a>) to drop that voltage down to 5V, which is connected to the LED strips power supply.</li>
<li>Resist the urge to just get a 5V power supply and connect it to both the arduous 5V pin and the LED strip, unless you have a good regulated 5V supply.</li>
</ul>
<p><a href="/wp-content/uploads/2015/11/rgb_leds_dc_jack.png" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-689 size-large" src="/wp-content/uploads/2015/11/rgb_leds_dc_jack-1024x420.png" alt="rgb_leds_dc_jack" width="640" height="263" srcset="/wp-content/uploads/2015/11/rgb_leds_dc_jack-1024x420.png 1024w, /wp-content/uploads/2015/11/rgb_leds_dc_jack-300x123.png 300w, /wp-content/uploads/2015/11/rgb_leds_dc_jack-768x315.png 768w, /wp-content/uploads/2015/11/rgb_leds_dc_jack-1536x631.png 1536w, /wp-content/uploads/2015/11/rgb_leds_dc_jack-1568x644.png 1568w, /wp-content/uploads/2015/11/rgb_leds_dc_jack.png 1644w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<h2>A little more safety to this circuit</h2>
<p>The soldering of wiring to the LED strip is often problematic, and the area is often moved / stressed / bent.  This can cause the electrical connection to come loose, short or form an intermittent contact.</p>
<p>We may want to protect the first LED package in the strip from damage caused by too much current passing though the data line (I suggest using a 330 ohm resistor).  It&#8217;s also not a bad idea to provide a 1000uF decoupling capacitor (use an electrolytic capacitor and watch the polarity). Without this you risk a wiring issue, or power connection issue, damaging the first LED unit on the strip.</p>
<p>In practice, you may never have a problem without these extra components, and the damage is often repaired easily by removing the first pixel and re-soldering. So the decision is yours, a &#8216;best practice&#8217; version of the above circuits is shown below.</p>
<p>&nbsp;</p>
<p><a href="/wp-content/uploads/2015/11/rgb_leds_better.png" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-690 size-large" src="/wp-content/uploads/2015/11/rgb_leds_better-1024x739.png" alt="rgb_leds_better" width="640" height="462" srcset="/wp-content/uploads/2015/11/rgb_leds_better-1024x739.png 1024w, /wp-content/uploads/2015/11/rgb_leds_better-300x217.png 300w, /wp-content/uploads/2015/11/rgb_leds_better-768x554.png 768w, /wp-content/uploads/2015/11/rgb_leds_better-1536x1109.png 1536w, /wp-content/uploads/2015/11/rgb_leds_better-1568x1132.png 1568w, /wp-content/uploads/2015/11/rgb_leds_better.png 1833w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>&nbsp;</p>
<h2>Watchout for ground loops</h2>
<p>If you need more power than just the USB connection you will have to give some thought to protecting your computer from ground loops.</p>
<p>The possibility of a ground loop exists when your arduino is connected to the PC via a USB cable and both the arduino (or connected circuitry) and the PC are mains connected in some way (even via a plug pack).</p>
<p>Possible solutions include:</p>
<ul>
<li>USB isolator (eg: <a href="http://amzn.to/1Pktq7r" target="_blank" rel="noopener">this one</a>)</li>
<li>Powering the PC from battery (eg laptop)</li>
<li>Powering the arduino from battery (eg 6v SLA)</li>
<li>Powering the arduino and circuitry from a plug-pack and using a wireless connection to communicate to the arduino</li>
<li>Don&#8217;t connect the usb cable
<ul>
<li>Use a network enabled board (the network ports are very well isolated). The <a href="http://www.freetronics.com.au/products/etherten#.VkCYO7crJhE" target="_blank" rel="noopener">etherten </a>is great for this.</li>
<li>Use wifi via a $5 esp8266 (for example <a href="http://amzn.to/1QdHAY4" target="_blank" rel="noopener">this one</a>)</li>
<li>Use an infra red serial connection (2400 baud)</li>
</ul>
</li>
<li>Just live with a potential ground loop
<ul>
<li>Plug everything into the same wall socket and keep your fingers crossed.</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<h3>Basic arduino code to test out the LED Strip</h3>
<p>Now we have to check our electrical project functions as predicted. For this article, and part 2, I will be using the <a href="https://github.com/nethoncho/FastSPI_LED2" target="_blank" rel="noopener">FastSPI_LED2 </a>library from  <a href="http://fastled.io/" target="_blank" rel="noopener">fastled.io</a>.</p>
<p>This demo code will create the effect shown in the video at the top of this article. If all you wanted was cool looking bias lighting, your&#8217;e done!</p>
<pre class="font:monospace height-set:true height:500 lang:c++ decode:true ">#include "FastSPI_LED2.h"

//----------------------------------------------------------------------------------------
//
// LED stip driver for smooth HUE trnsitions radiating from the middle of the LED strip.
//
//----------------------------------------------------------------------------------------

//Alter this to suit your setup
#define NUM_LEDS 91
#define PIN_LED 4

//This is where the individual pixel for ever LED is stored.
//use LEDS.show(); to sync the strip with the data in this array.
struct CRGB leds[NUM_LEDS];

void setup() 
{
	  // sanity check delay - allows reprogramming if accidently blowing power w/leds
   	delay(2000);

   	//to prevent too high  a power draw use 25% brightness
   	LEDS.setBrightness(64);

    //setup the LED controller
    LEDS.addLeds&lt;WS2811, PIN_LED, RGB&gt;(leds, NUM_LEDS);
}


void loop()
{ 
  byte hueMiddle=0;
  byte hueEdge=0;
  byte hueStep = 48;
  int maxHue = 255; //NB: hue may not be in the range 0-255, if we use a differnt hsv2rgb function.
  bool sync = false;
  
  while(true)
  {
    //pause a second
    delay(1000);

    //push the hue of the middle part of the bias light forward
    for(int s=0; s&lt; hueStep; s++)
    {
        hueMiddle++;
        if(hueMiddle &gt;= maxHue)
        {
          sync = true;
          break;
        }
        updateStrip(hueMiddle, hueEdge);
    }

    //have the edge of the bias light catch up to the hue in the middle
    for(int s=0; s&lt; hueStep; s++)
    {
        hueEdge++;
        if(hueEdge &gt;= maxHue)
        {
          sync = true;
          break;
        }
       updateStrip(hueMiddle, hueEdge);
    }

    // Reached the end of the hue cycle, wrap to the begining.
    // We do it this way because if the hueMiddle wraps around, but the
    // hueEdge remains before the end, then a full rainbow is creted
    // when updateStrip smooths the pixels over the strip
    if(sync)
    {
       hueMiddle = 0;
       hueEdge = 0;
       sync = false;
    } 
  }
}


// This method creates a smooth transition of pixels, from one hue in the middle
// to another hue at the edge.
//
//note: Could be faster with symetry away from middle.
//note: Could be faster with integer math.
//note: Because of the long delay, this does not need to be fast.
void updateStrip(byte hueMiddle, byte hueEdge)
{
    float mid = NUM_LEDS/2;
    int hueDiff =  hueEdge - hueMiddle;
    for(int i = 0; i &lt; NUM_LEDS; i++) 
    {
        //get the hue for the pixel
        CRGB pixel;
        float h = abs(i-mid)/mid; //0 at mid, 1 at edge
        h *= hueDiff; //0 at mid, hueDiff at edge
        h += hueMiddle; //hueMiddle at mid, hueEdge at edge

        //set the pixel
        hsv2rgb_spectrum(CHSV((byte)round(h), 255, 255), pixel);
        leds[i] = pixel;
    }
    delay(150);
    LEDS.show();
}
</pre>
<p>&nbsp;</p>
<h3>What&#8217;s next?</h3>
<p>In a follow-up article (part-2) we will cover syncing your arduino to the computers clock, choosing good colours for different times of the day and using your location to calculate where the sun is (in case you want to tune your your lighting to the time of the day).</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>When a picture is worth 1000 semilegible words.</title>
		<link>/when-a-picture-is-worth-1000-semilegible-words/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Wed, 19 Aug 2015 18:52:52 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[Meme]]></category>
		<category><![CDATA[Observing society]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=537</guid>

					<description><![CDATA[(click for full size) &#160; &#160; All these uni adverts with different reasons you should attend them. None say &#8220;Hey south paws, you can actually take notes if you enrol with us&#8221;.]]></description>
										<content:encoded><![CDATA[<p>(click for full size)<br />
&nbsp;</p>
<p><a href="/wp-content/uploads/2015/08/uni_diversity_small2.jpg" target="_blank" rel="noopener"><img loading="lazy" class="alignnone wp-image-629" src="/wp-content/uploads/2015/08/uni_diversity_small2-234x300.jpg" alt="uni_diversity_small2" width="500" height="642" srcset="/wp-content/uploads/2015/08/uni_diversity_small2-234x300.jpg 234w, /wp-content/uploads/2015/08/uni_diversity_small2-798x1024.jpg 798w, /wp-content/uploads/2015/08/uni_diversity_small2-768x986.jpg 768w, /wp-content/uploads/2015/08/uni_diversity_small2.jpg 800w" sizes="(max-width: 500px) 100vw, 500px" /></a></p>
<p>&nbsp;</p>
<p>All these uni adverts with different reasons you should attend them.<br />
None say &#8220;Hey south paws, you can actually take notes if you enrol with us&#8221;.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>I reckon my fan guard design is pretty damn neat.  (Free Plans)</title>
		<link>/i-reckon-my-fan-guard-design-is-pretty-damn-neat-free-plans/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Mon, 17 Aug 2015 19:13:24 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAM]]></category>
		<category><![CDATA[DXF]]></category>
		<category><![CDATA[Laser_Cutter]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=597</guid>

					<description><![CDATA[I needed some fan guards for my arcade machine and for a neat little entertainment centre hack. Playing around I made a fish-eye honey-comb screen that looked pretty good. The pattern has larger holes near the centre of the fan and smaller holes where it counts.]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<h3>Introduction:</h3>
<p>I needed some fan guards for my arcade machine and for a neat little <a href="http://busyducks.com/wp_4_1/2015/08/17/cheap-and-easy-temperature-controlled-cabinate-fan/">entertainment centre hack</a>.</p>
<p>Playing around I made a fish-eye honey-comb screen that looked pretty good. The pattern has larger holes near the centre of the fan and smaller holes where it counts.</p>
<p><a href="/wp-content/uploads/2015/08/fan_grill.jpg"><img loading="lazy" class="alignnone size-medium wp-image-602" src="/wp-content/uploads/2015/08/fan_grill-300x266.jpg" alt="fan_grill" width="300" height="266" srcset="/wp-content/uploads/2015/08/fan_grill-300x266.jpg 300w, /wp-content/uploads/2015/08/fan_grill-768x681.jpg 768w, /wp-content/uploads/2015/08/fan_grill.jpg 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<h3>How to make your own (with plans):</h3>
<p>Making this is pretty easy if you have a laser cutter. If you don&#8217;t grab the .dxf  file and head of to your local laser/acrylic cutting business or makerspace.</p>
<p><a href="/wp-content/uploads/2015/08/rendered_plans.png"><img loading="lazy" class="alignnone wp-image-603 size-large" src="/wp-content/uploads/2015/08/rendered_plans-1024x507.png" alt="rendered_plans" width="640" height="317" srcset="/wp-content/uploads/2015/08/rendered_plans-1024x507.png 1024w, /wp-content/uploads/2015/08/rendered_plans-300x149.png 300w, /wp-content/uploads/2015/08/rendered_plans-768x380.png 768w, /wp-content/uploads/2015/08/rendered_plans-1536x761.png 1536w, /wp-content/uploads/2015/08/rendered_plans-1568x776.png 1568w, /wp-content/uploads/2015/08/rendered_plans.png 1969w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>The .dxf file is downloadable <a href="http://www.busyducks.com/downloads/dxf/fans_and_template.dxf" target="_blank" rel="noopener noreferrer">here</a>.<br />
A printable .png (good for the template) is downloadable <a href="http://www.busyducks.com/downloads/dxf/fans_and_template.png" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><strong>Q: I&#8217;m too lazy, can you sell me one?</strong></p>
<p>Not any more (sorry).</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Practical Iterative K-ary Tree (aka n-ary, n-tree) Traversal in C#.  A surprisingly useful tool for the average programmer.</title>
		<link>/practical-generic-k-ary-tree-n-tree-traversal-in-c/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Mon, 10 Aug 2015 15:02:54 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Educational]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Data_Structures]]></category>
		<category><![CDATA[Edcucational]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[WDLib]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=546</guid>

					<description><![CDATA[Introduction: A lot of components in the C# environment are essentially a K-ary [kay-er-ee] tree. From tree-view nodes, to serialising a type via reflection, to directory listings to menu hierarchies, and so on. Often we need to iterate through these types of structures, or our own trees, and we just write some code to do &#8230;<br><a href="/practical-generic-k-ary-tree-n-tree-traversal-in-c/" class="more-link pen_button pen_element_default pen_icon_arrow_double">Continue reading <span class="screen-reader-text">Practical Iterative K-ary Tree (aka n-ary, n-tree) Traversal in C#.  A surprisingly useful tool for the average programmer.</span></a>]]></description>
										<content:encoded><![CDATA[<h3>Introduction:</h3>
<p>A lot of components in the C# environment are essentially a K-ary [kay-er-ee] tree. From tree-view nodes, to serialising a type via reflection, to directory listings to menu hierarchies, and so on.</p>
<p>Often we need to iterate through these types of structures, or our own trees, and we just write some code to do it as needed. This code is often problematic as it&#8217;s non-trivial to do well, because:</p>
<ul>
<li>It&#8217;s complex to do certain traversals in an iterative manor. (non recursive);</li>
<li>Traversal is prone to bugs, as there are many edge cases;</li>
<li>Software hangs if a circular reference exists and you don&#8217;t catch it;</li>
<li>Unit-testing of once-off code is often neglected;</li>
<li>Examining / verifying correct behaviour of tree traversal algorithms is difficult in the debugger.</li>
</ul>
<p>Wanting to rid myself of this re-occurring situation I built a few helper methods to do the following traversals iteratively:</p>
<ul>
<li>Depth First Pre Order</li>
<li>Depth First Post Order,</li>
<li>Breadth First</li>
</ul>
<p>The helpers are generic [BYO data type] and dont require a specific interface. You just supply a Func to return a nodes sub nodes. Thus you can drop a working tested algorithm onto whatever situation you encounter.</p>
<h3>Iteration</h3>
<p>Example:</p>
<ul>
<li>Made using an example data type &#8220;Node&#8221;
<ul>
<li>See the unit-tests at the  bottom of the page for implementation</li>
</ul>
</li>
<li>First it shows using a foreach loop on a depth first pre-order iterator</li>
<li>Then is shows using a breadth-first iterator to convert a tree to an array using Linq.</li>
</ul>
<pre class="lang:c# decode:true">/*
* Test tree
*                  A
*                / | \ 
*              B   C   D
*            / |       | \
*          E   F       G   H
*        / |         / | \
*       I  J        K  L  M
*/
Node&lt;char&gt; tree = Node&lt;char&gt;.TestTree();

//EXAMPLE 1: Pre-order traversal via foreach loop
foreach(var node in  Misc.EnumerateNodes(tree, 
                                    N =&gt; N.Nodes, 
                                    NodeVisitOrder.DepthFirstPreOrder))
{
    Console.Out.Write(node.Item);
}
Console.Out.WriteLine();
//outputs ABEIJFCDGKLMH

//EXAMPLE 2: Creating an array via breadth first traversal 
string s = new String(Misc.EnumerateNodes(tree, N =&gt; N.Nodes, NodeVisitOrder.BredthFirst)
                            .Select(N =&gt; N.Item)
                            .ToArray());
Console.Out.WriteLine(s);
//outputs ABCDEFGHIJKLM</pre>
<p>This was a simplistic example, but it works, its unit-tested, its efficient and non-recursive. It all ties into linq and IEnumerable so many neat tricks are possible.</p>
<p>Lets examine the crucial line in detail.</p>
<pre class="lang:c# decode:true">EnumerateNodes(tree, N =&gt; N.Nodes, NodeVisitOrder.DepthFirstPreOrder)
</pre>
<ul>
<li>The first parameter is the root node. This is method is generic, so any class type will do.</li>
<li>The second is a lambda expression for an enumerable  set of sub-nodes</li>
<li>The third is the traversal method.</li>
</ul>
<p>Another example of how flexible the method is, using DirectoryInfo as the node, and iterating over all subdirectories:</p>
<ul>
<li>This time we use the optional forth parameter to enable circular reference checking. this prevents any chance of an infinite loop</li>
</ul>
<pre class="lang:c# decode:true">DirectoryInfo root = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
 
var dirs = Misc.EnumerateNodes(
                root,
                N =&gt; { try { return N.GetDirectories();  } 
                       catch (Exception) { return null; } },
                NodeVisitOrder.DepthFirstPreOrder, 
                CircularRefernceBehaviour.Skip);
 
foreach (var dir in dirs)
{
}</pre>
<h3>Duplication</h3>
<p>Often you just need to copy one tree structure to another (possibly of a different type):</p>
<ul>
<li>Loading a directory structure into a TreeView control</li>
<li>Turning a tree of commands into Menu Items</li>
<li>Working with expression parsing  and evaluation</li>
<li>Just making a deep copy of a tree structure</li>
</ul>
<pre class="lang:c# decode:true">/*
* Test tree
*                  A
*                / | \ 
*              B   C   D
*            / |       | \
*          E   F       G   H
*        / |         / | \
*       I  J        K  L  M
*/
Node&lt;char&gt; tree = Node&lt;char&gt;.TestTree();

TreeNode n = Misc.RebuildTree(tree,  
							 N =&gt; N.Nodes, 
							 N =&gt; new TreeNode("" + N.Item), 
							 (T, N) =&gt; T.Nodes.AddRange(N.ToArray()));</pre>
<p>Neeto, one line of code, and our <span style="text-decoration: underline;">tree is duplicated into a TreeView</span> (or whatever) in a efficient, reliable manor.</p>
<p>RebuildTree takes five parameters:</p>
<ol>
<li>The root of the tree to be copied.</li>
<li>Func for an enumerating sub-nodes in the source structure</li>
<li>Func to create a new destination  node form a source node
<ul>
<li>Just the data of the node, Leave the child nodes unpopulated</li>
</ul>
</li>
<li>Action to add a collection of Nodes to an existing node (destination structure)</li>
<li>Circular reference checking behaviour</li>
</ol>
<h3>Core Algorithms</h3>
<h4>Depth First Pre-Order</h4>
<ul>
<li>Note: visitOk(&#8230;) returns true unless a circular reference is detected.</li>
<li>This works by feeding al nodes onto a stack, a basic way to resolve the recursion.</li>
<li>Child nodes are pushed in reverse order, so they are pop&#8217;ed in the correct order.</li>
</ul>
<pre class="lang:c# decode:true">LinkedList list = new LinkedList();
HashSet visited = new HashSet();

list.AddLast(node);
while (list.Count &gt; 0)
{
	T item = list.Pop();
	if (visitOk(item, visited, checkType))
	{
		yield return item;
		list.AddLastAll(getSubNodesSafe(item, getSubNodes).Reverse());
	}
}
</pre>
<h4>Depth First Post-Order</h4>
<ul>
<li>Depth First Post-Order is actually pretty tricky, a few algorithms exist.</li>
<li>This one initially traverses the entire tree O(n) to fill a stack, then returns each item in the stack.</li>
<li>The overall time is O(n), with the first iteration being O(n) and all subsequent  iterations being O(1)</li>
<li>There s a requirement for  extra memory for this to work, but its not too bad.</li>
</ul>
<pre class="lang:c# decode:true">LinkedList list = new LinkedList();
HashSet visited = new HashSet();

Stack output = new Stack();
list.AddLast(node);
while (list.Count &gt; 0)
{
	T item = list.Pop();
	if (visitOk(item, visited, checkType))
	{
		output.Push(item);
		list.AddLastAll(getSubNodesSafe(item, getSubNodes));
	}
}
foreach (T item in output)
{
	yield return item;
}

</pre>
<h4>Breadth First</h4>
<ul>
<li>This works by feeding al nodes onto a queue, as opposed to the depth first &#8211; pre order, which uses a stack.
<ul>
<li>This time Child nodes are not added in reverse order, however</li>
</ul>
</li>
</ul>
<pre class="lang:c# decode:true">LinkedList list = new LinkedList();
HashSet visited = new HashSet();

list.AddLast(node);
while (list.Count &gt; 0)
{
	T item = list.Dequeue();
	if (visitOk(item, visited, checkType))
	{
		yield return item;
		list.AddLastAll(getSubNodesSafe(item, getSubNodes));
	}
}
break;
}
</pre>
<h3>Source Code:</h3>
<pre class="height-set:true lang:c# decode:true ">/*
Available under the BSD 3-Clause License
Copyright (c) 2015, Dr Warren Creemers All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using WD_toolbox;

namespace WD_toolbox
{
    public enum NodeVisitOrder { DepthFirstPreOrder, DepthFirstPostOrder, BredthFirst }

    public enum CircularRefernceBehaviour { DontCheck, ThrowException, Skip }

    public class NodeTraversalException : Exception
    {
        public NodeTraversalException(string message) : base(message) { }
        public NodeTraversalException() : base() { }
        public static NodeTraversalException VisitedTwice(object item) {return new NodeTraversalException("Node already visied: " + item.ToString());} 
    }

    public static class Misc
    {
        /// &lt;summary&gt;
        /// Enumerates any Tree/graph in a non-recursive manor.
        /// Does not check for circularReferences.
        /// &lt;/summary&gt;
        /// &lt;param name="node"&gt;Root node.&lt;/param&gt;
        /// &lt;param name="getSubNodes"&gt; Get the sub-nodes of any given node.&lt;/param&gt;
        /// &lt;param name="order"&gt;The visit order.&lt;/param&gt;
        /// &lt;param name="checkType"&gt;If circular references should be checked, and how to handle them. 
        /// Note (1): Checks repeated node, which is not nesesiarly a circular reference (but all circulare references have a repeated node).
        /// Note (2): performance hit reduced if  node generates a good hashcode.
        /// &lt;/param&gt;
        public static IEnumerable&lt;T&gt; EnumerateNodes&lt;T&gt;( T node, 
                                                        Func&lt;T, IEnumerable&lt;T&gt;&gt; getSubNodes,
                                                        NodeVisitOrder order = NodeVisitOrder.DepthFirstPreOrder,
                                                        CircularRefernceBehaviour checkType = CircularRefernceBehaviour.DontCheck)
            where T : class
        {
            if (node != null) //assuming null indicats an empty tree
            {
                //this acts as a stack or queue to resolve the recursion
                LinkedList&lt;T&gt; list = new LinkedList&lt;T&gt;();
                HashSet&lt;T&gt; visited = new HashSet&lt;T&gt;();

                switch (order)
                {
                    case NodeVisitOrder.DepthFirstPreOrder:
                        list.AddLast(node);
                        while (list.Count &gt; 0)
                        {
                            T item = list.Pop();
                            if (visitOk(item, visited, checkType))
                            {
                                yield return item;
                                list.AddLastAll(getSubNodesSafe(item, getSubNodes).Reverse());
                            }
                        }
                        break;

                    case NodeVisitOrder.DepthFirstPostOrder:
                        //This has a side effects, the first iteeration is slow (also memory consuming) 
                        //as the entire structure is copied into a stack 
                        Stack&lt;T&gt; output = new Stack&lt;T&gt;();
                        list.AddLast(node);
                        while (list.Count &gt; 0)
                        {
                            T item = list.Pop();
                            if (visitOk(item, visited, checkType))
                            {
                                output.Push(item);
                                list.AddLastAll(getSubNodesSafe(item, getSubNodes));
                            }
                        }
                        foreach (T item in output)
                        {
                            yield return item;
                        }
                        break;

                    case NodeVisitOrder.BredthFirst:
                        list.AddLast(node);
                        while (list.Count &gt; 0)
                        {
                            T item = list.Dequeue();
                            if (visitOk(item, visited, checkType))
                            {
                                yield return item;
                                list.AddLastAll(getSubNodesSafe(item, getSubNodes));
                            }
                        }
                        break;
                }
            }
        }

        // Because getSubNodes(T) may return null to indicate no nodes.
        private static IEnumerable&lt;T&gt; getSubNodesSafe&lt;T&gt;(T node, Func&lt;T, IEnumerable&lt;T&gt;&gt; getSubNodes)
        {
            if ((node != null) &amp;&amp; (getSubNodes != null))
            {
                IEnumerable&lt;T&gt; subNodes = getSubNodes(node);
                return (subNodes != null) ? subNodes : new List&lt;T&gt;();
            }
            return new List&lt;T&gt;();
        }

        private static bool visitOk&lt;T&gt;(T item, HashSet&lt;T&gt; visited, CircularRefernceBehaviour checkType)
        {
            if (checkType != CircularRefernceBehaviour.DontCheck)
            {
                if (visited.Contains(item))
                {
                    // error
                    if (checkType == CircularRefernceBehaviour.ThrowException)
                    {
                        throw NodeTraversalException.VisitedTwice(item);
                    }
                    return false; //indicate it's not ok to visit (ie skip)
                }

                //no error
                visited.Add(item);
                return true;
            }

            //no check
            return true;
        }


        /// &lt;summary&gt;
        /// Copies a tree structure. (useful in copying a tree structure to a tree view).
        /// &lt;/summary&gt;
        /// &lt;typeparam name="A"&gt;The node type of the tree to copy.&lt;/typeparam&gt;
        /// &lt;typeparam name="B"&gt;The destination node type.&lt;/typeparam&gt;
        /// /// &lt;param name="getSubNodes"&gt; Get the sub-nodes of any given node.&lt;/param&gt;
        /// &lt;param name="newNode"&gt;To create a simple non-recursive copy of a node.&lt;/param&gt;
        /// &lt;param name="addSubNodes"&gt;&lt;/param&gt;
        /// &lt;param name="checkType"&gt; Type of circular reference checking to perform.&lt;/param&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public static B RebuildTree&lt;A, B&gt;(A srcNode,
                                           Func&lt;A, IEnumerable&lt;A&gt;&gt; getSubNodes,
                                           Func&lt;A, B&gt; newNode,
                                           Action&lt;B, IEnumerable&lt;B&gt;&gt; addSubNodes,
                                           CircularRefernceBehaviour checkType = CircularRefernceBehaviour.DontCheck)
            where A : class
            where B : class
        {
            return RebuildTree(srcNode, getSubNodes, newNode, addSubNodes, P =&gt; true, checkType);
        }
        
        /// &lt;summary&gt;
        /// Copies a tree structure. (useful in copying a tree structure to a tree view).
        /// &lt;/summary&gt;
        /// &lt;typeparam name="A"&gt;The node type of the tree to copy.&lt;/typeparam&gt;
        /// &lt;typeparam name="B"&gt;The destination node type.&lt;/typeparam&gt;
        /// /// &lt;param name="getSubNodes"&gt; Get the sub-nodes of any given node.&lt;/param&gt;
        /// &lt;param name="newNode"&gt;To create a simple non-recursive copy of a node.&lt;/param&gt;
        /// &lt;param name="addSubNodes"&gt;&lt;/param&gt;
        /// &lt;param name="where"&gt;&lt;/param&gt;
        /// &lt;param name="checkType"&gt; Type of circular reference checking to perform.&lt;/param&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public static B RebuildTree&lt;A, B&gt;( A srcNode,
                                           Func&lt;A, IEnumerable&lt;A&gt;&gt; getSubNodes, 
                                           Func&lt;A, B&gt; newNode,
                                           Action&lt;B, IEnumerable&lt;B&gt;&gt; addSubNodes,
                                           Predicate&lt;A&gt; where,
                                           CircularRefernceBehaviour checkType = CircularRefernceBehaviour.DontCheck)
            where A : class
            where B : class
        {


            LinkedList&lt;Tuple&lt;A, B&gt;&gt; list = new LinkedList&lt;Tuple&lt;A, B&gt;&gt;();
            HashSet&lt;A&gt; visited = new HashSet&lt;A&gt;();
            B newRootNode = null;

            list.AddLast(new Tuple&lt;A, B&gt;(srcNode, null));
            while (list.Count &gt; 0)
            {
                var tuple = list.Pop();
                A item = tuple.Item1;
                B parent = tuple.Item2;

                if (visitOk(item, visited, checkType))
                {
                    if (where(item))
                    {
                        B newItem = newNode(item);
                        if (newRootNode == null) //root node
                        {
                            newRootNode = newItem;
                        }

                        safeAddSubNode(parent, newItem, addSubNodes);
                        
                        list.AddLastAll(getSubNodesSafe(item, getSubNodes).Reverse().Select(N =&gt; new Tuple&lt;A, B&gt;(N, newItem)));
                    }
                }
            }

            //done
            return newRootNode;
        }

        private static void safeAddSubNode&lt;B&gt;(B parent, B child, Action&lt;B, IEnumerable&lt;B&gt;&gt; addSubNodes)
        {
            if ((addSubNodes != null) &amp;&amp; (parent != null) &amp;&amp; (child != null))
            {
                addSubNodes(parent, new B[] { child });
            }
        }
    }
}
</pre>
<p>Requires The following Extension class to make LinkedList sane.</p>
<pre class="height-set:true height:500 lang:c# decode:true ">/*
Available under the BSD 3-Clause License
Copyright (c) 2015, Dr Warren Creemers All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/// &lt;summary&gt;
/// These extensions make usage of the LinkedList more consise.
/// &lt;/summary&gt;
public static class LinkedListExtension
{
	/// &lt;summary&gt;
	/// Pops the last value of the linked list.
	/// &lt;/summary&gt;
	/// &lt;returns&gt; Value of the (formerly) last item in the list. &lt;/returns&gt;
	/// &lt;exception cref="System.InvalidOperationException"&gt; The LinkedList is empty.&lt;/exception&gt;
	public static T Pop&lt;T&gt;(this LinkedList&lt;T&gt; list)
	{
		T item = list.Last.Value;
		list.RemoveLast(); //throws InvalidOperationException
		return item;
	}

	/// &lt;summary&gt;
	/// Dequeues the first value of the linked list.
	/// &lt;/summary&gt;
	/// &lt;returns&gt; Value of the (formerly) first item in the list. &lt;/returns&gt;
	/// &lt;exception cref="System.InvalidOperationException"&gt; The LinkedList is empty.&lt;/exception&gt;
	public static T Dequeue&lt;T&gt;(this LinkedList&lt;T&gt; list)
	{
		T item = list.First.Value;
		list.RemoveFirst(); //throws InvalidOperationException
		return item;
	}

	/// &lt;summary&gt;
	/// Gets the last value of the linked list.
	/// &lt;/summary&gt;
	/// &lt;returns&gt; Value of the last item in the list. &lt;/returns&gt;
	/// &lt;exception cref="System.InvalidOperationException"&gt; The LinkedList is empty.&lt;/exception&gt;
	public static T PeekLast&lt;T&gt;(this LinkedList&lt;T&gt; list)
	{
		if (list.Count &lt;= 0)
		{
			throw new InvalidOperationException("LinkedList is empty (call to PeekLast)");
		}

		T item = list.Last.Value;
		return item;
	}

	/// &lt;summary&gt;
	/// Gets the last value of the linked list.
	/// &lt;/summary&gt;
	/// &lt;returns&gt; Value of the last item in the list. &lt;/returns&gt;
	/// &lt;exception cref="System.InvalidOperationException"&gt; The LinkedList is empty.&lt;/exception&gt;
	public static T PeekFirst&lt;T&gt;(this LinkedList&lt;T&gt; list)
	{
		if (list.Count &lt;= 0)
		{
			throw new InvalidOperationException("LinkedList is empty (call to PeekFirst)");
		}

		T item = list.First.Value;
		return item;
	}

	/// &lt;summary&gt;
	/// Addss items to the end of the list.
	/// &lt;/summary&gt;
	/// &lt;param name="items"&gt;Items to add.&lt;/param&gt;
	public static void AddLastAll&lt;T&gt;(this LinkedList&lt;T&gt; list, IEnumerable&lt;T&gt; items)
	{
		foreach (T item in items)
		{
			list.AddLast(item);
		}
	}

	/// &lt;summary&gt;
	/// Addss items to the end of the list.
	/// &lt;/summary&gt;
	/// &lt;param name="items"&gt;Items to add.&lt;/param&gt;
	public static void AddFirstAll&lt;T&gt;(this LinkedList&lt;T&gt; list, IEnumerable&lt;T&gt; items)
	{
		foreach (T item in items)
		{
			list.AddFirst(item);
		}
	}
}</pre>
<h3>Unit Tests:</h3>
<pre class="height-set:true height:500 lang:c# decode:true ">       [TestMethod()]
        public void EnumerateNodesTest()
        {
            /*
            * Test tree
            *                  A
            *                / | \ 
            *              B   C   D
            *            / |       | \
            *          E   F       G   H
            *        / |         / | \
            *       I  J        K  L  M
            */
            Node&lt;char&gt; tree = Node&lt;char&gt;.TestTree();

            Node&lt;char&gt; coruptTree = Node&lt;char&gt;.TestTree();
            //point L  to A
            coruptTree.Nodes[2].Nodes[0].Nodes[1].Nodes.Add(coruptTree); 

            //DepthFirstPreOrder
            string res = new String(Misc.EnumerateNodes(tree, N =&gt; N.Nodes, 
                                                        NodeVisitOrder.DepthFirstPreOrder, 
                                                        CircularRefernceBehaviour.ThrowException).Select(N =&gt; N.Item).ToArray());



            //System.Diagnostics.Trace.WriteLine("Hello World");
            Assert.AreEqual("ABEIJFCDGKLMH", res);
            
            //DepthFirstProstOrder
            res = new String(Misc.EnumerateNodes(tree, N =&gt; N.Nodes, 
                                                    NodeVisitOrder.DepthFirstPostOrder,
                                                    CircularRefernceBehaviour.ThrowException).Select(N =&gt; N.Item).ToArray());
            Assert.IsTrue(res == "IJEFBCKLMGHDA");

            //BredthFirst
            res = new String(Misc.EnumerateNodes(tree, N =&gt; N.Nodes, 
                                                 NodeVisitOrder.BredthFirst,
                                                 CircularRefernceBehaviour.ThrowException).Select(N =&gt; N.Item).ToArray());
            Assert.AreEqual("ABCDEFGHIJKLM", res);

            //just to check no exception thrown
            TreeNode n = Misc.RebuildTree(tree,  
                                         N =&gt; N.Nodes, 
                                         N =&gt; new TreeNode("" + N.Item),
                                         (T, N) =&gt; T.Nodes.AddRange(N.ToArray()), 
                                         CircularRefernceBehaviour.ThrowException);

            //Check an exception is thrown for curupted tree

            try
            {
                n = Misc.RebuildTree(coruptTree,
                                             N =&gt; N.Nodes,
                                             N =&gt; new TreeNode("" + N.Item),
                                             (T, N) =&gt; T.Nodes.AddRange(N.ToArray()),
                                             CircularRefernceBehaviour.ThrowException);

                Assert.Fail("Should never reach this line of code");
            }
            catch (Exception)
            {
            }

            //Just handle a corupt tree by not going backward.
            n = Misc.RebuildTree(coruptTree,
                                 N =&gt; N.Nodes,
                                 N =&gt; new TreeNode("" + N.Item),
                                 (T, N) =&gt; T.Nodes.AddRange(N.ToArray()),
                                 CircularRefernceBehaviour.Skip);

            //NB: Infinite loop on fail

        }

        

        public class Node&lt;T&gt;
        {
            public List&lt;Node&lt;T&gt;&gt; Nodes = new List&lt;Node&lt;T&gt;&gt;();
            public T Item;
            public Node(T item, IList&lt;Node&lt;T&gt;&gt; nodes = null)
            {
                Item = item;
                if (nodes != null)
                {
                    Nodes.AddRange(nodes);
                }
            }

            private static Node&lt;T&gt; NODE&lt;T&gt;(T item, params Node&lt;T&gt;[] Nodes)
            {
                return new Node&lt;T&gt;(item, Nodes);
            }

            public static Node&lt;char&gt; TestTree()
            {
                /*
                * Test tree
                *                  A
                *                / | \ 
                *              B   C   D
                *            / |       | \
                *          E   F       G   H
                *        / |         / | \
                *       I  J        K  L  M
                */


                Node&lt;char&gt; tree =
                    NODE('A',
                        NODE('B',
                            NODE('E',
                                NODE('I'),
                                NODE('J')
                                ),
                            NODE('F')
                            ),
                        NODE('C'),
                        NODE('D',
                            NODE('G',
                                NODE('K'),
                                NODE('L'),
                                NODE('M')
                                ),
                            NODE('H')
                            )
                        );

                return tree;
            }
        }
    }</pre>
<h3>WDLib Library:</h3>
<p>This is part of my personal toolbox, WDLib (in the misc class, which is abridged for clarity on this page). I am moving to open source the library at the moment.</p>
<h3>Limitations and Usage:</h3>
<ul>
<li>The circular reference check just checks for a repeated node, which is not necessarily a circular reference (but all circular references have a repeated node). This may deny some malformed trees that could otherwise be safely parsed. Checking can always be disabled if this is your intent.</li>
<li>Be aware the first iteration of the Depth First Post-Order has a O(n) overhead.</li>
</ul>
<h3></h3>
<h3>Contact / Feedback</h3>
<p>[Sorry I had to remove this, because hundreds of spam emails about SEO]</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>10 simple things search engines could do to save my sanity</title>
		<link>/10-simple-things-search-engines-could-do-to-save-my-sanity/</link>
		
		<dc:creator><![CDATA[duckman]]></dc:creator>
		<pubDate>Thu, 30 Jul 2015 04:40:42 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[HCI]]></category>
		<category><![CDATA[List_of]]></category>
		<category><![CDATA[Observing society]]></category>
		<guid isPermaLink="false">http://busyducks.com/wp_4_1/?p=524</guid>

					<description><![CDATA[I have felt for a while that web searching is still an awkward thing from a Human Computer Interaction point of view. So I made a wish list of simple improvements that would literally turn my world upside-down.]]></description>
										<content:encoded><![CDATA[<h3>Introduction</h3>
<p>I have felt for a while that web searching is still an awkward thing from a Human Computer Interaction point of view. So I made this wish list of simple improvements that would turn my world upside-down.</p>
<h3>10 simple things search engines could do to save my sanity.</h3>
<ol>
<li>NOT display a 10 item &#8220;first page&#8221;, just keep results coming as I scroll down.</li>
<li>Let me filter results by subject. (ie. shopping, info, blog, pop-culture, education, forums)</li>
<li>Display Icons next to the search result that tell me what I am in for:
<ul>
<li>A sound icon if the site auto-plays music / video.</li>
<li>Flash/java/etc icons if the website uses such</li>
<li>Warn me about pop-ups, &#8220;intro banners&#8221; and exit prompts.</li>
<li>NSFW Icon</li>
<li>Does not support my browser/device icon.</li>
<li>Valid security certificate icon.</li>
<li>Something to indicate if most people left the site within 10 seconds of it loading.</li>
</ul>
</li>
<li>Often the 2 sentences from the page shown below the result is just not enough. Give me a &#8220;more&#8221; link that expands a results preview to a couple of paragraphs.
<ul>
<li>If lots of people expand a particular pages preview, then just automatically do that for me.</li>
</ul>
</li>
<li>Let me blacklist a domain from all my future web-searches. (Eg If I don&#8217;t like pintrist, let me remove it from my search results permanently).
<ul>
<li>If a lot of other people have blacklisted a domain, give me a warning icon.</li>
</ul>
</li>
<li>Be like <a href="https://www.virustotal.com/">virustotal.com</a> and let me query how the site fairs against assorted virus checks.</li>
<li>Don&#8217;t make me type in the address bar. Ending up at www,paint.net if I search &#8220;paint.net&#8221; is stupid. The whole thing is awkward and reaks of being overly dumbed-down.</li>
<li>Bundle multiple results from the same domain into an expandable result. Eg &#8220;[+] 50 results for rubberducks in ebay.com&#8221;</li>
<li>If the webpage is largely plagiarised&#8230; tell me and provide links to original sites(s) under the link.</li>
<li>If other web pages address the page or website I am about to visit, let me expand a section to see what people are saying.</li>
</ol>
<p>&nbsp;</p>
<h3>Conclusion</h3>
<p>Web searching still remains very much the same as its was in the mid 90&#8217;s.</p>
<p>The list I have created draws out certain underlying problems that were never addressed.</p>
<ul>
<li>When I follow a result to a new website, I just don&#8217;t know &#8220;what is behind the door&#8221;. I have to click an hope for the best. It&#8217;s 2015 and that this is still a problem seems odd.</li>
<li>I lack control over what comes up in my results. SEO tactics dominate what I see, and my &#8220;intent&#8221; is often ignored.</li>
<li>Websites exist in a context. They reference, each other and elaborate on each others information. We need to encapsulate this.</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
