<?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>The Electronics Hobbyist &#187; circuit</title>
	<atom:link href="http://www.theelectronicshobbyist.com/blog/tag/circuit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theelectronicshobbyist.com/blog</link>
	<description>A Passion for Curiosity and Play</description>
	<lastBuildDate>Fri, 20 Jan 2012 14:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Motion and Light Sensors with Arduino (and Without)</title>
		<link>http://www.theelectronicshobbyist.com/blog/motion-and-light-sensors-with-arduino-and-without/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/motion-and-light-sensors-with-arduino-and-without/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 08:00:13 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Reader Mailbag]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[diode]]></category>
		<category><![CDATA[LDR]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[light dependent resistor]]></category>
		<category><![CDATA[logic probe]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[multimeter]]></category>
		<category><![CDATA[PIR]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[transistor]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=606</guid>
		<description><![CDATA[I have recently received the following question from a reader: I&#8217;m looking for a circuit board design that will need to turn on an array of LEDs when motion is detected during the day time, and also stay on continuously during the night time; using the Arduino would be nice. The project that I am [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I have recently received the following question from a reader:</p>
<blockquote><p>I&#8217;m looking for a circuit board design that will need to turn on an array of LEDs when motion is detected during the day time, and also stay on continuously during the night time; using the Arduino would be nice. The project that I am working on is just a picture frame with my artwork in it. The art is actually an embossed piece. The light that I am placing within the frame will shine across the embossed art, and reflect off the raised areas of paper and make the picture appear more three-dimensional. So, the picture acts as a night light when it&#8217;s dark, and then turns on for a moment during the day time when some approaches the picture.</p></blockquote>
<p>I suspected there had to be a simple circuit to accomplish this without having to program a microcontroller to take care of triggering the light. I could see that was overkill; after all, it is just a way to switch lights on/off. Still, I had no idea how to do it, if not from a software point of view.<br />
<span id="more-606"></span><br />
Well, he mentioned the Arduino in his email, and I wanted to give him a quick response, so I put together a prototype to achieve the effect he desired. I properly warned him that might not be the best solution, but since he wanted to tinker with the Arduino, that would be a simple sketch.</p>
<p>I suggested the use of a compact Arduino clone like the <a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny">Ardweeny</a> (check out &#8220;<a title="LED Bar Graph: Testing the Ardweeny" href="http://www.theelectronicshobbyist.com/blog/led-bar-graph-testing-the-ardweeny/">Testing the Ardweeny</a>&#8221; to see how tiny it is!)</p>
<p>Then, soldering everything onto a stripboard should result in a small footprint that would not detract from his art piece.</p>
<p>Anyway, here&#8217;s a <a href="http://fritzing.org/" target="_blank">Fritzing</a> diagram that shows how to wire the circuit:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/fritzing1.jpg"><img class="alignnone  wp-image-635" title="fritzing1" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/fritzing1.jpg" alt="Fritzing diagram for motion-triggered light using Arduino" width="557" height="601" /></a></p>
<p>You can see the Arduino, LDR (light sensor, the component with the &#8220;squiggly&#8221; line), LED and PIR (motion sensor, the black &#8220;mystery&#8221; component to the right &#8212; the Fritzing version I&#8217;m using has no PIR component and I still don&#8217;t know how to add a custom component the proper way).</p>
<p>Here&#8217;s an <a href="http://www.ladyada.net/learn/sensors/pir.html" target="_blank">excellent tutorial</a> on the use of PIRs, from Ladyada who did create her own component on Fritzing.</p>
<p>And here&#8217;s a picture of the setup:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/pic1.jpg"><img class="alignnone  wp-image-639" title="pic1" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/pic1.jpg" alt="Circuit for the motion-triggered light with Arduino" width="570" height="492" /></a></p>
<p>Bill of Materials (include parts used for both Arduino and non-Arduino* versions):</p>
<ul>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4651" target="_blank">Breadboard</a></li>
<li>Power* (I used <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4414" target="_blank">this breakout board</a> connected to my USB; power pins only)</li>
<li>1 <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_202403_-1" target="_blank">photocell</a> (light dependent resistor/LDR)</li>
<li>1 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4290" target="_blank">motion sensor</a> (passive infrared sensor/PIR)</li>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4447" target="_blank">Arduino</a> (any flavor)</li>
<li>1 NPN transistor* (<a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_254781_-1" target="_blank">BC548B</a>) (for the PIR)</li>
<li>1 PNP transistor* (<a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_178618_-1" target="_blank">2N3906</a>) (for the LDR)</li>
<li>2 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4383" target="_blank">10K Ohm resistors</a>* (Arduino version uses only 1)</li>
<li>2 diodes (<a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_655269_-1" target="_blank">1N914A</a>)*</li>
<li>1 <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_94714_-1" target="_blank">10K trimpot</a>*</li>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4242" target="_blank">Jumper wire</a> (male-to-male, assorted lengths)</li>
<li>1 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4215" target="_blank">LED</a></li>
<li>2 180 Ohm resistors* (<a href="http://www.theelectronicshobbyist.com/blog/goto/uno" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/uno';return true;" onmouseout="self.status=''">Arduino</a> version uses only 1) (<a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4374" target="_blank">200 Ohm</a> will work, too)</li>
<li><a href="http://www.amazon.com/gp/product/B000FLVJ3Q/ref=as_li_ss_tl?ie=UTF8&amp;tag=mpu-proj-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=B000FLVJ3Q" target="_blank">Multimeter</a> (optional, but helpful)</li>
<li><a href="http://www.amazon.com/gp/product/B000Z9HAP4/ref=as_li_ss_tl?ie=UTF8&amp;tag=mpu-proj-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=B000Z9HAP4" target="_blank">Logic probe</a> (optional, but helpful)</li>
</ul>
<p>Here&#8217;s a <a href="http://www.youtube.com/watch?v=QuzCGq8SZPM" target="_blank">video</a> showing the concept:</p>
<p>(On a side note I have now acquired a HD flip camera so I don&#8217;t have to use my phone to record videos anymore).</p>
<p>OK, here’s the Arduino sketch:</p>
<pre><span style="color: #7e7e7e;">/* www.TheElectronicsHobbyist.com/blog</span>
<span style="color: #7e7e7e;"> * Natalia Fargasch Norman</span>
<span style="color: #7e7e7e;"> * Motion detection using Arduino</span>
<span style="color: #7e7e7e;"> */</span>

#define LDR 0
#define PIR 2
#define LED 3

<span style="color: #cc6600;">int</span> pirState;
<span style="color: #cc6600;">int</span> ldrValue;

<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><strong>setup</strong></span>() {
  <span style="color: #7e7e7e;">//Serial.begin(9600);</span>
  <span style="color: #cc6600;">pinMode</span>(LED, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #cc6600;">pinMode</span>(PIR, <span style="color: #006699;">INPUT</span>);
  <span style="color: #cc6600;">digitalWrite</span>(LED, <span style="color: #006699;">LOW</span>);
}

<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><strong>loop</strong></span>(){
  ldrValue = <span style="color: #cc6600;">analogRead</span>(LDR);
  <span style="color: #7e7e7e;">//Serial.print("Analog reading = ");</span>
  <span style="color: #7e7e7e;">//Serial.println(ldrValue);</span>

  <span style="color: #cc6600;">if</span> (ldrValue &lt;= 512) { <span style="color: #7e7e7e;">// dark</span>
    <span style="color: #cc6600;">digitalWrite</span>(LED, <span style="color: #006699;">HIGH</span>);
  } 
  <span style="color: #cc6600;">else</span> { <span style="color: #7e7e7e;">// ldrValue &gt; 512</span>
    pirState = <span style="color: #cc6600;">digitalRead</span>(PIR);
    <span style="color: #cc6600;">if</span> (pirState == <span style="color: #006699;">HIGH</span>) {
      <span style="color: #cc6600;">digitalWrite</span>(LED, <span style="color: #006699;">HIGH</span>);
      <span style="color: #cc6600;">delay</span>(5000);
      <span style="color: #cc6600;">digitalWrite</span>(LED, <span style="color: #006699;">LOW</span>);
      <span style="color: #cc6600;">delay</span>(1000);
    } 
    <span style="color: #cc6600;">else</span> { <span style="color: #7e7e7e;">// pirState == LOW</span>
      <span style="color: #cc6600;">digitalWrite</span>(LED, <span style="color: #006699;">LOW</span>);
    }
  }
  <span style="color: #7e7e7e;">// The processing in the Arduino occurs faster</span>
  <span style="color: #7e7e7e;">// than the response from the PIR, and adding this delay</span>
  <span style="color: #7e7e7e;">// eliminated a flickering on the LED</span>
  <span style="color: #cc6600;">delay</span>(1000);
}</pre>
<p>The idea is to trigger the light when it&#8217;s dark; otherwise, trigger it for a short duration if motion is detected. This simple Arduino sketch does just that. A light dependent resistor is connected to an analog pin on the Arduino, and reading from it will either trigger the light (if it&#8217;s dark) or have the Arduino check for motion by reading from the motion sensor connected to a digital pin (if it&#8217;s not dark).</p>
<h3>And finally&#8230; a non-Arduino version!</h3>
<p>A few days and a couple of aha! moments later, I finally figured out how to accomplish the same behavior without using a microcontroller.</p>
<p>I knew an OR gate could be used to trigger the LED (output) on either (or both, doesn&#8217;t matter) condition: darkness or motion detected. The PIR outputs either 0 (no motion detected) or 1 (motion detected). But what about the light detection piece of the circuit? The LDR gives me an analog reading, and I needed a 0 or a 1 as inputs to the OR gate.</p>
<p>When later reading about transistors in Forrest Mims&#8217; &#8220;<a href="http://www.amazon.com/gp/product/0945053282/ref=as_li_ss_tl?ie=UTF8&amp;tag=mpu-proj-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0945053282" target="_blank">Getting Started in Electronics</a>&#8221; it occurred to me that I could use one as a switch on the LDR part of the circuit to generate the second input to the OR gate.</p>
<p>So I excitedly went to Marvac (my trusty local electronics shop) to buy OR gates; unfortunately, they were out of stock&#8230; <img src='http://www.theelectronicshobbyist.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>But then, again courtesy of Forrest Mims, I learned how to build my own OR gate using two rectifier diodes. (And I had the necessary parts!)</p>
<p>Here&#8217;s how it&#8217;s wired:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/or.jpg"><img class="alignnone size-medium wp-image-630" title="diode-or-gate" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/or-202x300.jpg" alt="Diode OR Gate" width="202" height="300" /></a></p>
<h3>Now on to the complete circuit&#8230;</h3>
<p>First I hooked up the LED to the OR circuit to test that it worked. <em>Check</em>.</p>
<p>Then I connected the PIR to the LED to make sure that it woks, i.e. LED lights up when there is motion detected. <em>Check</em>.</p>
<p>Then I connected the PIR to be the first input of the OR gate&#8230; <em>and it didn&#8217;t work</em>.</p>
<p>I hooked up the LDR as the second input to the OR gate and that part&#8230; <em>&#8220;kind of&#8221; worked</em>. (LED off when dark and on when light; should be the other way around). I had used an NPN transistor, so I just switched to a PNP instead and it worked. Makes sense!</p>
<p>This is how it was hooked up: Emitter to ground, Collector to load (the LED) and Base to LDR. The LDR was connected to a 10K <a title="Pull Up Resistors" href="http://www.theelectronicshobbyist.com/blog/pull-up-resistors/">pull-up resistor</a> and a potentiometer (to fine tune the amount of darkness it takes to trigger the LED).</p>
<p>But the PIR part of the circuit was still &#8220;kaputt&#8221;&#8230; I checked with the logic probe and found out that there was a signal coming to the LED. I replaced it with a diffused LED and could see that it was actually on, just veeeery faint.</p>
<p>Using a multimeter I measured the voltage between the LED leads and it was 2.3V. My power source was 4.92V. It seems that the PIR causes a voltage drop&#8230;</p>
<p>Then I looked at the datasheet for the Parallax PIR I have (note to self: that should definitely NOT be an afterthought), and learned that there are two versions, and that mine requires a transistor or a MOSFET to drive external loads.</p>
<p>I hooked up a random (I&#8217;m no EE!) transistor (a 2N2222) and now the LED is brighter. But still not as bright as when I cover the LDR.</p>
<p>Looking at the current values, my multimeter read:</p>
<blockquote><p>Current through the LED when the LDR portion of the circuit is active: 4.2mA<br />
Current through the LED when the PIR portion of the circuit is active: 0.8mA</p></blockquote>
<p>The only other transistors I had were 2N3904, so I decided to try that one. The LED was much brighter and the current read 2.4mA. With a base current of 0.02mA I was getting a gain of 40 with the 2N2222 and 120 with the 2N3904.</p>
<p>I checked the datasheets for these two transistors, and these gain values were consistent. After some research it seems the BC548B is a better amplifier transistor for this application, and has a minimum gain of 200.</p>
<p>Here’s what the circuit looks like on Fritzing:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/fritzing2.jpg"><img class="alignnone  wp-image-636" title="fritzing2" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/fritzing2-1024x339.jpg" alt="Fritzing diagram for motion-triggered light" width="553" height="183" /></a></p>
<p>And here’s a picture of the real thing:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/pic2.jpg"><img class="alignnone  wp-image-640" title="pic2" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/12/pic2.jpg" alt="Circuit for the motion-triggered light" width="576" height="432" /></a></p>
<p>By the way, I heard back from my reader; he bought the <a href="http://www.ladyada.net/make/boarduino/" target="_blank">Boarduino from Adafruit</a>, not the <a href="http://www.theelectronicshobbyist.com/blog/led-bar-graph-testing-the-ardweeny/" title="LED Bar Graph: Testing the Ardweeny">Ardweeny</a>, and successfully built his &#8220;darkness-or-motion-triggered artwork illumination&#8221; project.</p>
<p>Keep sending me your questions; I love to see what you are working on, and it helps me on my learning journey as well. (Explaining something to somebody else is the best way to learn). I will also from time to time publish some of your questions here. (If you have an electronics blog let me know and I will include it here).</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/motion-and-light-sensors-with-arduino-and-without/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>LED Bar Graph: Testing the Ardweeny</title>
		<link>http://www.theelectronicshobbyist.com/blog/led-bar-graph-testing-the-ardweeny/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/led-bar-graph-testing-the-ardweeny/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 01:00:25 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino Clone]]></category>
		<category><![CDATA[Kit]]></category>
		<category><![CDATA[Ardweeny]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[kit]]></category>
		<category><![CDATA[LED bar graph]]></category>
		<category><![CDATA[schematic]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[soldering]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=409</guid>
		<description><![CDATA[A while ago I purchased an Ardweeny kit, but hadn&#8217;t put it together and tested it until now. The Ardweeny is a small, breadboard friendly Arduino clone. In fact, it is the smallest Arduino clone that I know of, and the tiny board is backpacked on top of the ATMega chip. Here are the parts [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>A while ago I purchased an <a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny">Ardweeny kit</a>, but hadn&#8217;t put it together and tested it until now. The <a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/ardweeny';return true;" onmouseout="self.status=''">Ardweeny</a> is a small, <a href="http://www.theelectronicshobbyist.com/blog/goto/breadboard" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/breadboard';return true;" onmouseout="self.status=''">breadboard</a> friendly <a href="http://www.theelectronicshobbyist.com/blog/goto/uno" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/uno';return true;" onmouseout="self.status=''">Arduino</a> clone. In fact, it is the smallest Arduino clone that I know of, and the tiny board is backpacked on top of the ATMega chip.<br />
<a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="size-medium wp-image-410 aligncenter" title="ardweeny" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-300x196.jpg" alt="Ardweeny" width="300" height="196" /></a><br />
Here are the parts laid out before I put the Ardweeny together: PCB, ATMega, headers and 7 parts. <em>Tip: double check that you received the correct parts; I received a 470K Ohm resistor (yellow-violet-yellow) instead of a 470 Ohm (yellow-violet-brown) one.</em><br />
<span id="more-409"></span><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-parts.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-430" title="ardweeny-parts" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-parts-300x200.jpg" alt="Ardweeny parts" width="300" height="200" /></a><br />
The assembly manual that comes with the Ardweeny is illustrated in color, and explains how to put it together in great detail, step-by-step. It is a very easy kit to put together, perfect for a beginner. There isn&#8217;t a lot of soldering involved, either. (There are only 7 parts after all!)<br />
<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-manual.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-431" title="ardweeny-manual" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-manual-300x234.jpg" alt="Ardweeny manual" width="300" height="234" /></a><br />
Here is the final product, assembled and ready to go! Isn&#8217;t it tiny? The <a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny">Ardweeny</a> comes preloaded with the &#8220;Blink&#8221; sketch. In order to program it you will need an <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4414&amp;affiliate_banner_id=1" target="_blank">FTDI breakout board</a> and <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4191&amp;affiliate_banner_id=1" target="_blank">USB miniB cable</a>. Upon hooking it up for the first time the green LED should blink.<br />
<a href="http://www.theelectronicshobbyist.com/blog/goto/ardweeny" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-432" title="ardweeny-finished" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-finished-300x261.jpg" alt="Ardweeny" width="300" height="261" /></a><br />
To test it I put together a simple circuit connecting a LED bar graph display and a variable resistor to the Ardweeny. Turning the dial on the trimpot lights the LEDs on the bar graph display accordingly. Here&#8217;s the setup:<br />
<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-led-bar.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-433" title="ardweeny-led-bar" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-led-bar-300x243.jpg" alt="Ardweeny LED bar graph project" width="300" height="243" /></a><br />
Here&#8217;s the schematic showing how the circuit was wired:<br />
<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-schematic.jpg"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-435" title="ardweeny-schematic" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/11/ardweeny-schematic-258x300.jpg" alt="Ardweeny LED bar graph schematic" width="258" height="300" /></a><br />
Here&#8217;s a quick <a href="http://www.youtube.com/watch?v=u2ZY6b3FGxg" target="_blank">video</a> of the Ardweeny in action.</p>
<p>And here&#8217;s the sketch:</p>
<pre>// www.TheElectronicsHobbyist.com/blog
// Natalia Fargasch Norman
// Trimpot display using LED bar graph

// loop variables and trimpot reading
int i, j, val;

void setup() {
  for (i = 0; i &lt; 10; i++) {
    pinMode(i, OUTPUT);
  }
}

void loop() {
  for (i = 0; i &lt; 10; i++) {
    digitalWrite(i, HIGH);
  }
  // trimpot connected to analog pin 0
  val = analogRead(0);
  // analogRead returns number
  // between 0 and 1023, scaling
  // for the 10 LEDs in the bar graph
  j = val / 100;
  for (i = 0; i &lt; j; i++) {
    // LED bar graph is common anode, LOW is on
    digitalWrite(i, LOW);
  }
}</pre>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/led-bar-graph-testing-the-ardweeny/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pull Up Resistors</title>
		<link>http://www.theelectronicshobbyist.com/blog/pull-up-resistors/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/pull-up-resistors/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 05:00:37 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[pull up resistor]]></category>
		<category><![CDATA[resistor]]></category>
		<category><![CDATA[schematic]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=361</guid>
		<description><![CDATA[If you&#8217;ve read Getting Started with Arduino (click on link to read my review of the book) you must have noticed that the circuit on page 43 uses a 10K Ohm resistor in series with the pushbutton. (If you haven&#8217;t read it yet, the example in the schematic on the right is similar to the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/09/pullup.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-medium wp-image-362" title="pullup" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/09/pullup-185x300.jpg" alt="Pull up resistors" width="250" /></a>If you&#8217;ve read <a href="http://www.theelectronicshobbyist.com/book/arduino-book.shtml" target="_blank">Getting Started with Arduino</a> (click on link to read my review of the book) you must have noticed that the circuit on page 43 uses a 10K Ohm resistor in series with the pushbutton. (If you haven&#8217;t read it yet, the example in the schematic on the right is similar to the setup featured on the book).</p>
<p>Consider a microcontroller with a digital input pin connected to a switch. When the switch is closed, the pin is connected to GND. When the switch is open, the signal is not connected to anything and is left at an unknown state. The signal is in this case said to be &#8220;floating&#8221;. This is pictured in circuit (1).</p>
<p>To remedy this problem we pull the signal up to VCC, as shown in circuit (2). Now when the switch is open the signal is connected directly to VCC and is at a known state. But notice that when the switch is closed, VCC and GND are connected, creating a short.<br />
<span id="more-361"></span><br />
To prevent the short we place a resistor between the input pin and VCC, as shown in circuit (3). This resistor is called a &#8220;pull up&#8221; resistor.</p>
<p>Pull down resistors work almost in the same way, except the circuit is connected so that when the switch is closed the input pin is connected to VCC, and when switch is open the pin is connected to GND using a &#8220;pull down&#8221; resistor, as shown in circuit (4).</p>
<p>A common value for pull up resistors is 10K Ohm. Higher resistance may be necessary for circuits that sink greater currents. We can use Ohm&#8217;s Law to determine the appropriate value for the resistor.</p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/basic-hobby-electronics-vocabulary-part-3-of-4-i-r/' rel='bookmark' title='Basic Hobby Electronics Vocabulary Part 3 of 4 (I-R)'>Basic Hobby Electronics Vocabulary Part 3 of 4 (I-R)</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch-schematic/' rel='bookmark' title='Arduino LED Control Using DIP Switch: Schematic | Part 2'>Arduino LED Control Using DIP Switch: Schematic | Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/pull-up-resistors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arduino Motor Control for the Spinning Night Light &#124; Part 3</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-motor-control-spinning-night-light/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-motor-control-spinning-night-light/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 05:00:40 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[diode]]></category>
		<category><![CDATA[motor]]></category>
		<category><![CDATA[transistor]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=325</guid>
		<description><![CDATA[Most motor control applications can be accomplished with a simple single-transistor circuit. This type of circuit controls the basic operation of turning the motor on and off, and allows very fast switching of the motor, which makes it possible to control the speed of the motor using pulse width modulation (PWM). The basic problem with [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/simple-motor-control.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="size-medium wp-image-326 alignright" title="simple-motor-control" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/simple-motor-control-286x300.jpg" alt="Simple motor control" width="286" height="300" /></a>Most motor control applications can be accomplished with a simple single-transistor circuit. This type of circuit controls the basic operation of turning the <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_2081895_-1" target="_blank">motor<img style="border: none !important; margin: 0px !important;" src="http://www.avantlink.com/tpv/10609/0/17253/21273/-/cl/image.png" alt="" width="0" height="0" /></a> on and off, and allows very fast switching of the motor, which makes it possible to control the speed of the motor using pulse width modulation (PWM).</p>
<p>The basic problem with this circuit is that the direction of the motor cannot be reversed. For our simple application in this <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4212&amp;affiliate_banner_id=1" target="_blank">RGB LED</a> night light, spinning the motor in one direction is enough. In the future we will use motors in applications which require us to reverse the direction as well, and for that we will be using the type of motor control circuit called H-bridge circuit.<br />
<span id="more-325"></span><br />
Note that a diode has been used in this circuit. The core of all types of motors is the inductor (or coil). When the amount of current (which can be moderate to high) passing through the inductor is changed, it produces large voltage spikes (&#8220;kickback&#8221; ) .</p>
<p>The diode used in <a href="http://www.theelectronicshobbyist.com/blog/goto/motor" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/motor';return true;" onmouseout="self.status=''">motor</a> control circuits is called a kickback diode and its purpose is to absorb the voltage that is produced when the transistor is turned on and off. When you are developing <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_2081895_-1" target="_blank">motor<img style="border: none !important; margin: 0px !important;" src="http://www.avantlink.com/tpv/10609/0/17253/21273/-/cl/image.png" alt="" width="0" height="0" /></a> control applications using a bipolar transistor you should always put in the kickback diode in order to protect the other parts of your circuit.</p>
<p>Here&#8217;s the <a href="http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/">sketch for the spinning night light</a>.</p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light-assembly/' rel='bookmark' title='Arduino RGB LED Spinning Night Light: Assembly | Part 2'>Arduino RGB LED Spinning Night Light: Assembly | Part 2</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light/' rel='bookmark' title='Arduino RGB LED Spinning Night Light | Part 1'>Arduino RGB LED Spinning Night Light | Part 1</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-control-spinning-night-light/' rel='bookmark' title='Arduino RGB LED Control for the Spinning Night Light | Part 4'>Arduino RGB LED Control for the Spinning Night Light | Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch-schematic/' rel='bookmark' title='Arduino LED Control Using DIP Switch: Schematic | Part 2'>Arduino LED Control Using DIP Switch: Schematic | Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-motor-control-spinning-night-light/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino RGB LED Spinning Night Light: Assembly &#124; Part 2</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light-assembly/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light-assembly/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 05:00:12 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[DC motor]]></category>
		<category><![CDATA[RGB LED]]></category>
		<category><![CDATA[soldering]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=312</guid>
		<description><![CDATA[Solder wires to motor terminals and cover with heat-shrink tubing Using a knife or sharp scissors, puncture a small hole (to fit the motor shaft snugly) on the center of the jar lid Solder motor shaft to jar lid (if necessary use hot glue or super glue, as some surfaces won&#8217;t &#8220;catch&#8221; the solder easily) [...]]]></description>
			<content:encoded><![CDATA[<p></p><ol>
<li><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight-schematic.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-medium wp-image-316" title="arduino-rgb-nightlight-schematic" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight-schematic-235x300.jpg" alt="Arduino RGB LED night light schematic" width="235" height="300" /></a>Solder <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4242&amp;affiliate_banner_id=1" target="_blank">wires</a> to <a href="http://www.theelectronicshobbyist.com/blog/goto/motor" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/motor';return true;" onmouseout="self.status=''">motor</a> terminals and cover with <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_419160_-1" target="_blank">heat-shrink tubing<img style="border: none !important; margin: 0px !important;" src="http://www.avantlink.com/tpv/10609/0/17253/21273/-/cl/image.png" alt="" width="0" height="0" /></a></li>
<li>Using a knife or sharp scissors, puncture a small hole (to fit the motor shaft snugly) on the center of the jar lid</li>
<li>Solder <a href="http://www.avantlink.com/click.php?tt=cl&amp;mi=10609&amp;pw=21273&amp;url=http%3A%2F%2Fwww.jameco.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2FProduct_10001_10001_2081895_-1" target="_blank">motor<img style="border: none !important; margin: 0px !important;" src="http://www.avantlink.com/tpv/10609/0/17253/21273/-/cl/image.png" alt="" width="0" height="0" /></a> shaft to jar lid (if necessary use hot glue or super glue, as some surfaces won&#8217;t &#8220;catch&#8221; the solder easily)</li>
<li>Solder the <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4212&amp;affiliate_banner_id=1" target="_blank">RGB LED</a> leads to long wires and cover the connections with heat-shrink tubing</li>
<li>Build the circuit on the <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4227&amp;affiliate_banner_id=1" target="_blank">mini breadboard</a> using the schematic as your guide</li>
<li>Prepare the paper diffuser (use a hole puncher and punch a few holes to allow some light to shine through) and tape it around the jar lid using mounting tape</li>
<p><span id="more-312"></span><br />
<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight-motor-mounting.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-medium wp-image-314" title="arduino-rgb-nightlight-motor-mounting" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight-motor-mounting-300x268.jpg" alt="motor leads" width="216" height="193" /></a></p>
<li>Mount the motor to the side of the <a href="http://www.theelectronicshobbyist.com/blog/goto/breadboard" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/breadboard';return true;" onmouseout="self.status=''">breadboard</a> using mounting tape</li>
<li>Tie the LED wires together and secure the wire bundle using a stick as prop (I used a lollipop stick in one of the holes on the breadboard); split the stick tip shaping it as a &#8220;Y&#8221; to help secure the LED wires in place(show finished picture)</li>
</ol>
<p>Check the previous post if you need to see the <a href="http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/">sketch for the Arduino RGB LED night light</a> again.</p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light/' rel='bookmark' title='Arduino RGB LED Spinning Night Light | Part 1'>Arduino RGB LED Spinning Night Light | Part 1</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-motor-control-spinning-night-light/' rel='bookmark' title='Arduino Motor Control for the Spinning Night Light | Part 3'>Arduino Motor Control for the Spinning Night Light | Part 3</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-control-spinning-night-light/' rel='bookmark' title='Arduino RGB LED Control for the Spinning Night Light | Part 4'>Arduino RGB LED Control for the Spinning Night Light | Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-circuit/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display Counter: Circuit | Part 2'>Arduino 2-Digit 7-Segment Display Counter: Circuit | Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display Counter: Circuit &#124; Part 2</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-circuit/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-circuit/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 05:00:29 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[7-segment display]]></category>
		<category><![CDATA[circuit]]></category>
		<category><![CDATA[transistor]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=202</guid>
		<description><![CDATA[This week we&#8217;ll look at the circuit for the 2-digit 7-segment display counter using the Arduino. There are a few options to control multiple displays: employing multiple controllers; using a 7-segment driver chip like the 7447; using a multi-display controller such as the MAXIM MAX7219; sequencing through the displays, which is what we have done [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This week we&#8217;ll look at the circuit for the 2-digit 7-segment display counter using the <a href="http://www.cutedigi.com/product_info.php?ref=3&#038;products_id=4221&#038;affiliate_banner_id=1" target="_blank">Arduino</a>.</p>
<p>There are a few options to control multiple displays:</p>
<ul>
<li>employing multiple controllers;</li>
<li>using a 7-segment driver chip like the 7447;</li>
<li>using a multi-display controller such as the MAXIM MAX7219;</li>
<li>sequencing through the displays, which is what we have done in our example, as it requires no added hardware.</li>
</ul>
<p>When we were using a <a href="http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-1-of-4/">single-digit display</a>, we connected the common anode pin to our Vdd supply, but with two digits we have to drive them independently if we want them to display different digits!</p>
<p>A natural reaction would be to try to use two Arduino I/O pins, each driving a digit of the display. The problem with this scenario is that it is not possible to drive the common anode or cathode pin using <a href="http://www.theelectronicshobbyist.com/blog/goto/uno" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/uno';return true;" onmouseout="self.status=''">Arduino</a> I/O pins, as they cannot source or sink enough current to light all seven segments.<br />
<span id="more-202"></span><br />
<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/led-displays.png"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft size-full wp-image-288" title="led-displays" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/led-displays.png" alt="2-digit 7-segment led display diagram" width="168" height="98" /></a>The solution is then to use bipolar junction transistors (NPN for common cathode and PNP for common anode displays) in order to sink or drive the required current. The controlling interface outputs the value for a specific display by enabling only its common pin transistor, and the digit driven by that common pin becomes active.</p>
<p>To give the impression that both displays are active at the same time and avoid flickering we cycle through the digits in quick succession and keep each of them lit for 5ms. We will see how that was implemented when we go over the sketch next week.</p>
<p>Here is the schematic for the circuit (click for larger image):<a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/2-digit-7-segment.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-medium wp-image-287" title="2-digit-7-segment" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/2-digit-7-segment-300x223.jpg" alt="2-digit 7-segment led display schematic" width="270" height="201" /></a></p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-sketch/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display Counter: Sketch | Part 3'>Arduino 2-Digit 7-Segment Display Counter: Sketch | Part 3</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display Counter | Part 1'>Arduino 2-Digit 7-Segment Display Counter | Part 1</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-with-buttons/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display with Buttons | Part 4'>Arduino 2-Digit 7-Segment Display with Buttons | Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-1-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 1'>Controlling a Seven-Segment Display Using Arduino Part 1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-circuit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.theelectronicshobbyist.com @ 2012-02-06 22:30:05 -->
