<?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</title>
	<atom:link href="http://www.theelectronicshobbyist.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theelectronicshobbyist.com/blog</link>
	<description>A Passion for Curiosity and Play</description>
	<lastBuildDate>Tue, 27 Jul 2010 05:00:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Arduino RGB LED Control for the Spinning Night Light</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 05:00:43 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[Ohm's Law]]></category>
		<category><![CDATA[resistor]]></category>
		<category><![CDATA[RGB LED]]></category>
		<category><![CDATA[sketch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=334</guid>
		<description><![CDATA[When looking at the parts list for the Arduino RGB LED spinning night light you must have noticed that current limiting resistors of different values were used for the Red and the Green/Blue pins of the RGB LED. That is due to them having different forward voltage ratings. You can find complete specs for the [...]]]></description>
			<content:encoded><![CDATA[<p>When looking at the <a href="http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/" target="_blank">parts list for the Arduino RGB LED spinning night light</a> you must have noticed that current limiting resistors of different values were used for the Red and the Green/Blue pins of 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>. That is due to them having different forward voltage ratings. You can find complete specs for the LED in the datasheet (when buying an electronic component you will have the option to download its datasheet, or the relevant information will be provided by the vendor).</p>
<p>We use <a href="http://en.wikipedia.org/wiki/Ohm's_law" target="_blank">Ohm&#8217;s Law</a> to calculate current limiting resistor values:</p>
<p>Forward voltage ratings:</p>
<blockquote><p>RED: 2.1V<br />
GREEN: 3.3V<br />
BLUE: 3.3V</p></blockquote>
<p>Current:</p>
<blockquote><p>I = 20mA</p></blockquote>
<p>Supply voltage:</p>
<blockquote><p>V = 5V</p></blockquote>
<p>Ohm&#8217;s Law:</p>
<blockquote><p>I = V/R =&gt; R = V/I</p></blockquote>
<p>So for Red:</p>
<blockquote><p>(5 &#8211; 2.1)/0.02 =&gt; R = 145 Ohm</p></blockquote>
<p>For Green/Blue:</p>
<blockquote><p>(5 &#8211; 3.3)/0.02 =&gt; R = 85 Ohm</p></blockquote>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/fade.jpg"><img class="size-medium wp-image-343 alignright" title="fade" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/fade-254x300.jpg" alt="color fading for the RGB LED night light" width="254" height="300" /></a>As for the Arduino sketch, I chose to have the lamp fade between two colors, aqua (#00FFFF) and magenta (#FF00FF). For that I kept the Blue value at 255 and varied the Green and Red values between 0-255 to achieve the desired colors, as shown in the diagram:<br />
(You can pick your favorite colors, cycle through the entire spectrum, or go psychedelic and show random colors with random delays)</p>
<pre>// fade from aqua to magenta
for (int i = 0; i &lt; 256; i++) {
  analogWrite(RED, i);
  analogWrite(GREEN, 255-i);
  analogWrite(BLUE, 255);
  delay(50);
}

// fade from magenta to aqua
for (int i = 0; i &lt; 256; i++) {
  analogWrite(RED, 255-i);
  analogWrite(GREEN, i);
  analogWrite(BLUE, 255);
  delay(50);
}</pre>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light'>Arduino RGB LED Spinning Night Light</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light-assembly/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light: Assembly'>Arduino RGB LED Spinning Night Light: Assembly</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-motor-control-spinning-night-light/' rel='bookmark' title='Permanent Link: Arduino Motor Control for the Spinning Night Light'>Arduino Motor Control for the Spinning Night Light</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Motor Control for the Spinning Night Light</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-motor-control-spinning-night-light/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/07/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><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/simple-motor-control.jpg"><img 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.trossenrobotics.com/store/p/5143-FF-030-Motor-6V.aspx?af=electronicshobbyist" target="_blank">motor</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 motor 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.trossenrobotics.com/store/p/5143-FF-030-Motor-6V.aspx?af=electronicshobbyist" target="_blank">motor</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>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/01/basic-hobby-electronics-vocabulary-part-2-of-4-d-g/' rel='bookmark' title='Permanent Link: Basic Hobby Electronics Vocabulary Part 2 of 4 (D-G)'>Basic Hobby Electronics Vocabulary Part 2 of 4 (D-G)</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light-assembly/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light: Assembly'>Arduino RGB LED Spinning Night Light: Assembly</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light'>Arduino RGB LED Spinning Night Light</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/' rel='bookmark' title='Permanent Link: Arduino RGB LED Control for the Spinning Night Light'>Arduino RGB LED Control for the Spinning Night Light</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-motor-control-spinning-night-light/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino RGB LED Spinning Night Light: Assembly</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light-assembly/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/07/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 gun or super glue, as some surfaces won&#8217;t &#8220;catch&#8221; the solder easily) [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight-schematic.jpg"><img 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 motor 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.trossenrobotics.com/store/p/5143-FF-030-Motor-6V.aspx?af=electronicshobbyist" target="_blank">motor</a> shaft to jar lid (if necessary use hot gun 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 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 breadboard 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/2010/07/arduino-rgb-led-spinning-night-light/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light'>Arduino RGB LED Spinning Night Light</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-motor-control-spinning-night-light/' rel='bookmark' title='Permanent Link: Arduino Motor Control for the Spinning Night Light'>Arduino Motor Control for the Spinning Night Light</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/' rel='bookmark' title='Permanent Link: Arduino RGB LED Control for the Spinning Night Light'>Arduino RGB LED Control for the Spinning Night Light</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino RGB LED Spinning Night Light</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 05:00:36 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[DC motor]]></category>
		<category><![CDATA[RGB LED]]></category>
		<category><![CDATA[sketch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=296</guid>
		<description><![CDATA[This month&#8217;s project uses the Arduino to control a motor and an RGB LED to create an aquarium style spinning night light. The initial idea was to recycle empty toilet paper tubes to serve as the lampshade, but it turns out the project looks much more attractive and colorful using white paper. (I haven&#8217;t given [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight.jpg"><img class="size-full wp-image-297 alignright" title="arduino-rgb-nightlight" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight.jpg" alt="Arduino RGB LED Night Light" width="350" height="175" /></a>This month&#8217;s project uses the Arduino to control a motor and an RGB LED to create an aquarium style spinning night light.</p>
<p>The initial idea was to recycle empty toilet paper tubes to serve as the lampshade, but it turns out the project looks much more attractive and colorful using white paper. (I haven&#8217;t given up on the idea of finding a use for the empty tubes, though. Suggestions are welcome.)</p>
<p>A simple DC motor is used to spin the lamp structure, and a jar lid serves as the base. There is (a lot of) room for improvement in the design of the lamp, but I&#8217;m a computer scientist and wanna-be crafter at best.<br />
<span id="more-296"></span><br />
I intend to revisit these projects in the future, and make them stand alone using smaller Arduino boards and sporting a nicer finish (something worthy of showing guests). For now the purpose of these projects is solely educational (in a microcontroller programming way, not hand crafting).</p>
<p>In the upcoming posts we will explore the assembly of the night light, as well as the circuit and Arduino sketch that make the project work.</p>
<p>Parts list:</p>
<ul>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4221&amp;affiliate_banner_id=1" target="_blank">Arduino Duemilanove</a></li>
<li><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></li>
<li><a href="http://www.trossenrobotics.com/store/p/5143-FF-030-Motor-6V.aspx?af=electronicshobbyist" target="_blank">DC Motor</a></li>
<li><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></li>
<li><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_36311_-1">1N914 Diode<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><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_178597_-1">2N3904 Transistor<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><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4373&amp;affiliate_banner_id=1" target="_blank">100 Ohm Resistor</a></li>
<li><a href="http://www.amazon.com/gp/product/B001AMWN1Q?ie=UTF8&amp;tag=mpu-proj-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001AMWN1Q">147 Ohm Resistor</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=mpu-proj-20&amp;l=as2&amp;o=1&amp;a=B001AMWN1Q" border="0" alt="" width="1" height="1" /></li>
<li><a href="http://www.amazon.com/gp/product/B0017KDZ4A?ie=UTF8&amp;tag=mpu-proj-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0017KDZ4A">82 Ohm Resistor</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=mpu-proj-20&amp;l=as2&amp;o=1&amp;a=B0017KDZ4A" border="0" alt="" width="1" height="1" /></li>
<li><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_116572_-1">Soldering iron<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><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_170457_-1">Solder<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><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">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><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4242&amp;affiliate_banner_id=1" target="_blank">Jumper Wires</a> of assorted lengths</li>
<li>White paper</li>
<li>Jar lid</li>
<li>Mounting tape</li>
</ul>
<p>I have recorded a short <a href="http://www.youtube.com/watch?v=zaAh-3RbcuY" target="_blank">video of the Arduino RGB LED Spinning Night Light</a> in action.</p>
<p>And here is the Arduino sketch:</p>
<pre>// www.TheElectronicsHobbyist.com/blog
// Natalia Fargasch Norman
// RGB LED night light using Arduino

// Arduino pins used for motor and LEDs
#define MOTOR 3
#define RED 9
#define GREEN 10
#define BLUE 11

// pins for motor and LEDs are outputs
void setup() {
  pinMode(MOTOR, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
}

void loop() {
  // set motor speed, between 0 and 255
  analogWrite(MOTOR, 69);

  // fade from aqua to magenta
  for (int i = 0; i &lt; 256; i++) {
    analogWrite(RED, i);
    analogWrite(GREEN, 255-i);
    analogWrite(BLUE, 255);
    delay(50);
  }

  // fade from magenta to aqua
  for (int i = 0; i &lt; 256; i++) {
    analogWrite(RED, 255-i);
    analogWrite(GREEN, i);
    analogWrite(BLUE, 255);
    delay(50);
  }

}</pre>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-control-spinning-night-ligh/' rel='bookmark' title='Permanent Link: Arduino RGB LED Control for the Spinning Night Light'>Arduino RGB LED Control for the Spinning Night Light</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light-assembly/' rel='bookmark' title='Permanent Link: Arduino RGB LED Spinning Night Light: Assembly'>Arduino RGB LED Spinning Night Light: Assembly</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 4'>Controlling a Seven-Segment Display Using Arduino Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display with Buttons: Sketch</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons-sketch/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons-sketch/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 05:00:26 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[7-segment display]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[sketch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=280</guid>
		<description><![CDATA[As you could see from last week&#8217;s full Arduino sketch listing, the source code for the 2-digit 7-segment display project using buttons is strikingly similar to the one without the buttons; praise for &#8216;copy and paste&#8216;! (It is worth noting, though, that &#8216;copy and paste&#8216; can be responsible for a higher percentage of bugs than [...]]]></description>
			<content:encoded><![CDATA[<p>As you could see from last week&#8217;s full <a href="http://www.cutedigi.com/product_info.php?ref=3&#038;products_id=4221&#038;affiliate_banner_id=1" target="_blank">Arduino</a> sketch listing, the source code for the 2-digit 7-segment display project using buttons is strikingly similar to the one without the buttons; praise for &#8216;<em>copy and paste</em>&#8216;! (It is worth noting, though, that &#8216;<em>copy and paste</em>&#8216; can be responsible for a higher percentage of bugs than I&#8217;d care to admit).</p>
<p>There are just a couple of snippets that I would like to comment on:</p>
<p>The first part of the loop() function checks whether either button has been pressed and increments the value of each digit.<br />
<span id="more-280"></span></p>
<pre>  // check button1
  int val1 = digitalRead(BTN1);
  if (val1 == HIGH) {
    digit1++;
    digit1 %= 10;
    delay(10);
  }

  // check button2
  int val2 = digitalRead(BTN2);
  if (val2 == HIGH) {
    digit2++;
    digit2 %= 10;
    delay(10);
  }</pre>
<p>The line</p>
<pre>    digit1 %= 10;</pre>
<p>which is shorthand for</p>
<pre>    digit1 = digit1 % 10;</pre>
<p>accomplishes the same as the line</p>
<pre>    if (count == 10) count = 0;</pre>
<p>that was used on the <a href="http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/">sketch for the single-digit 7-segment project</a> a couple of months ago. It updates digit1 with the remainder of the division of itself by 10, which will be zero when digit1 is 10. The latter code looks a bit more obvious for beginner programmers.</p>
<p>The last part of the loop() function refreshes the display, and is very similar to the <a href="http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/">sketch for the 2-digit 7-segment display counter</a>.</p>
<pre>  // display number
  unsigned long startTime = millis();
  for (unsigned long elapsed=0; elapsed &lt; 600; elapsed = millis() - startTime) {
    lightDigit1(numbers[digit1]);
    delay(5);
    lightDigit2(numbers[digit2]);
    delay(5);
  }</pre>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display with Buttons'>Arduino 2-Digit 7-Segment Display with Buttons</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter: Sketch'>Arduino 2-Digit 7-Segment Display Counter: Sketch</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter'>Arduino 2-Digit 7-Segment Display Counter</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 4'>Controlling a Seven-Segment Display Using Arduino Part 4</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons-sketch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display with Buttons</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 05:00:42 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[7-segment display]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=267</guid>
		<description><![CDATA[This week we modify the original circuit and sketch to include two buttons, one to control each digit of the display. Here&#8217;s what the setup looks like: And here&#8217;s the complete sketch: // www.TheElectronicsHobbyist.com/blog // Natalia Fargasch Norman // Dual seven-segment LED Display with buttons // Common Anode digit 1 pin 10 // Common Anode [...]]]></description>
			<content:encoded><![CDATA[<p>This week we modify the original circuit and sketch to include two buttons, one to control each digit of the display.</p>
<p>Here&#8217;s what the setup looks like:</p>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/seven-segment-button.jpg"><img class="aligncenter size-medium wp-image-268" title="seven-segment-button" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/06/seven-segment-button-300x216.jpg" alt="2-Digit 7-Segment Display" width="300" height="216" /></a></p>
<p>And here&#8217;s the complete sketch:<br />
<span id="more-267"></span></p>
<pre>// www.TheElectronicsHobbyist.com/blog
// Natalia Fargasch Norman
// Dual seven-segment LED Display with buttons
// Common Anode digit 1 pin 10
// Common Anode digit 2 pin 5

//       CA1 G  F  A  B
//        |  |  |  |  |      -&gt; pins and segments they control
//   ---------    ---------
//   |   A   |    |   A   |
//  F|       |B  F|       |B
//   |---G---|    |---G---|
//  E|       |C  E|       |C
//   |   D   |    |   D   |
//   ---------    ---------
//        |  |  |  |  |      -&gt; pins and segments they control
//        D  DP E  C CA2         

// Segments that make each number when lit:
// 0 =&gt; -FEDCBA
// 1 =&gt; ----BC-
// 2 =&gt; G-ED-BA
// 3 =&gt; G--DCBA
// 4 =&gt; GF--CB-
// 5 =&gt; GF-DC-A
// 6 =&gt; GFEDC-A
// 7 =&gt; ----CBA
// 8 =&gt; GFEDCBA
// 9 =&gt; GF-DCBA

// Arduino digital pins used to light up
// corresponding segments on the LED display
#define A 3
#define B 2
#define C 6
#define D 8
#define E 7
#define F 4
#define G 5

// Pushbuttons connected to pins 9 and 10
#define BTN1 9
#define BTN2 10

// Pins driving common anodes
#define CA1 13
#define CA2 12

// Pins for A B C D E F G, in sequence
const int segs[7] = { 3, 2, 6, 8, 7, 4, 5 };

// Segments that make each number
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010,
0b0000010, 0b1111000, 0b0000000, 0b0010000 };

int digit1 = 0;
int digit2 = 0;

void setup() {
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  pinMode(E, OUTPUT);
  pinMode(F, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(BTN1, INPUT);
  pinMode(BTN2, INPUT);
  pinMode(CA1, OUTPUT);
  pinMode(CA2, OUTPUT);
}

void loop() {

  // check button1
  int val1 = digitalRead(BTN1);
  if (val1 == HIGH) {
    digit1++;
    digit1 %= 10;
    delay(10);
  }

  // check button2
  int val2 = digitalRead(BTN2);
  if (val2 == HIGH) {
    digit2++;
    digit2 %= 10;
    delay(10);
  }

  // display number
  unsigned long startTime = millis();
  for (unsigned long elapsed=0; elapsed &lt; 600; elapsed = millis() - startTime) {
    lightDigit1(numbers[digit1]);
    delay(5);
    lightDigit2(numbers[digit2]);
    delay(5);
  }
}

void lightDigit1(byte number) {
  digitalWrite(CA1, LOW);
  digitalWrite(CA2, HIGH);
  lightSegments(number);
}

void lightDigit2(byte number) {
  digitalWrite(CA1, HIGH);
  digitalWrite(CA2, LOW);
  lightSegments(number);
}

void lightSegments(byte number) {
  for (int i = 0; i &lt; 7; i++) {
    int bit = bitRead(number, i);
    digitalWrite(segs[i], bit);
  }
}</pre>
<p>Here&#8217;s a video of the Arduino <a href="http://www.youtube.com/watch?v=NgssVuNDYgw" target="_blank">2-digit 7-segment display counter with buttons</a> in action.</p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter'>Arduino 2-Digit 7-Segment Display Counter</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 4'>Controlling a Seven-Segment Display Using Arduino Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter: Sketch'>Arduino 2-Digit 7-Segment Display Counter: Sketch</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display Counter: Sketch</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 05:00:54 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[7-segment display]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[common anode]]></category>
		<category><![CDATA[sketch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=207</guid>
		<description><![CDATA[This is part 3 in the project to control a 2-digit 7-segment display using an Arduino. Here is the first post on this 2-digit 7-segment display project. So now on the the meatier sections of the sketch for this project: Common anode displays are not immediately obvious as a segment is lit when the corresponding [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 3 in the project to control a 2-digit 7-segment display using an Arduino. Here is the <a href="http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter">first post on this 2-digit 7-segment display project</a>.</p>
<p>So now on the the meatier sections of the sketch for this project:</p>
<p>Common anode displays are not immediately obvious as a segment is lit when the corresponding pin is made LOW. You might  be surprised, though, that common anode displays are most often used because they can be used with 74xx series logic data-selector chips and PNP bipolar transistors.<br />
<span id="more-207"></span></p>
<pre>// Segments that make each number when lit:
// 0 =&gt; -FEDCBA
// 1 =&gt; ----BC-
// 2 =&gt; G-ED-BA
// 3 =&gt; G--DCBA
// 4 =&gt; GF--CB-
// 5 =&gt; GF-DC-A
// 6 =&gt; GFEDC-A
// 7 =&gt; ----CBA
// 8 =&gt; GFEDCBA
// 9 =&gt; GF-DCBA</pre>
<p>Remember, the Arduino pins are connected to the display&#8217;s cathodes. To light a segment we make the corresponding pin LOW.</p>
<p>We use 0s where the segments need to be lit up. The digit &#8216;zero&#8217;, for instance, is not the intuitive 0b0111111, but the less obvious 0b1000000.</p>
<pre>// Segments that make each number
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010,
0b0000010, 0b1111000, 0b0000000, 0b0010000 };</pre>
<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. This is implemented by adding a short delay after displaying each digit. Since numbers stay lit for 600 ms, the whole process is repeated 60 times for each number displayed, and thanks to Persistence of Vision (POV) we have the impressios that both digits are actually lit up at the same time. (Even though they are not).</p>
<p>The loop below is where the action takes place in our sketch: we cycle through both digits keeping each on for 5ms at a time for the 600ms during which we display each complete number.</p>
<pre>void loop() {
  for (int digit1=0; digit1 &lt; 10; digit1++) {
    for (int digit2=0; digit2 &lt; 10; digit2++) {
      unsigned long startTime = millis();
      for (unsigned long elapsed=0; elapsed &lt; 600; elapsed = millis() - startTime) {
        lightDigit1(numbers[digit1]);
        delay(5);
        lightDigit2(numbers[digit2]);
        delay(5);
      }
    }
  }
}</pre>
<p>The lightDigit function for digit 1 enables only the transistor for the common anode pin of the tens digit:</p>
<pre>void lightDigit1(byte number) {
  digitalWrite(CA1, LOW);
  digitalWrite(CA2, HIGH);
  lightSegments(number);
}</pre>
<p>The lightDigit function for digit 2 enables only the transistor for the common anode pin of the units digit:</p>
<pre>void lightDigit2(byte number) {
  digitalWrite(CA1, HIGH);
  digitalWrite(CA2, LOW);
  lightSegments(number);
}</pre>
<p>Function lightSegments was reused from the <a href="http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-1-of-4/">single-digit 7-segment sketch</a>:</p>
<pre>void lightSegments(byte number) {
  for (int i = 0; i &lt; 7; i++) {
    int bit = bitRead(number, i);
    digitalWrite(segs[i], bit);
  }
}</pre>
<p>Next week we will modify our project to use buttons to control each digit, and as such we&#8217;ll avoid having to cycle through several numbers in order to achieve the desired number being displayed (if that number is significantly greater than the current number being displayed).</p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display with Buttons'>Arduino 2-Digit 7-Segment Display with Buttons</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter'>Arduino 2-Digit 7-Segment Display Counter</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons-sketch/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display with Buttons: Sketch'>Arduino 2-Digit 7-Segment Display with Buttons: Sketch</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 4'>Controlling a Seven-Segment Display Using Arduino Part 4</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display Counter: Circuit</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-circuit/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/06/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>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 Arduino 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 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 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/2010/06/arduino-2-digit-7-segment-display-counter-sketch/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter: Sketch'>Arduino 2-Digit 7-Segment Display Counter: Sketch</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-1-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 1'>Controlling a Seven-Segment Display Using Arduino Part 1</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter'>Arduino 2-Digit 7-Segment Display Counter</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display with Buttons'>Arduino 2-Digit 7-Segment Display with Buttons</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-circuit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display Counter</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 05:00:28 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[7-segment display]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=185</guid>
		<description><![CDATA[This month&#8217;s Arduino project is to build two 2-digit 7-segment LED display circuits and sketches, one that counts up and one that counts up using mini push buttons. The next posts will explain the circuits and the Arduino sketches. Materials: Arduino Duemilanove 1 2-digit 7-segment display (I got a 50-piece LED display grab bag for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/2-digit-display.jpg"><img class="alignright size-medium wp-image-186" title="2-digit-display" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/2-digit-display-217x300.jpg" alt="2-digit 7-segment display" width="174" height="240" /></a>This month&#8217;s Arduino project is to build two 2-digit 7-segment LED display circuits and sketches, one that counts up and one that counts up using mini push buttons. The next posts will explain the circuits and the Arduino sketches.</p>
<p>Materials:</p>
<ul>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4221&amp;affiliate_banner_id=1" target="_blank">Arduino Duemilanove</a></li>
<li>1 2-digit 7-segment display (I got a <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_18201_-1" target="_blank">50-piece LED display grab bag<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> for better value; the one I used was configured as shown)</li>
<li>2 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4211&amp;affiliate_banner_id=1" target="_blank">Mini push button switches</a></li>
<li>9 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4373&amp;affiliate_banner_id=1" target="_blank">Resistors, 100 Ohm</a></li>
<li>2 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4383&amp;affiliate_banner_id=1" target="_blank">Resistors, 10K Ohm</a></li>
<p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/seven-segment-count.jpg"><img class="alignright size-medium wp-image-187" title="seven-segment-count" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/seven-segment-count-300x225.jpg" alt="2-digit 7-segment display project on breadboard" width="300" height="225" /></a></p>
<li>2 <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_38375_-1">2N3906 transistors (PNP)<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>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_194299_-1">Solderless breadboard<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><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4242&amp;affiliate_banner_id=1" target="_blank">Jumper Wires</a> in assorted lengths</li>
</ul>
<p>Sketch for counting up without buttons:<br />
<span id="more-185"></span></p>
<pre>// www.TheElectronicsHobbyist.com/blog
// Natalia Fargasch Norman
// Dual seven-segment LED Display
// Common Anode digit 1 pin 10
// Common Anode digit 2 pin 5

//       CA1 G  F  A  B
//        |  |  |  |  |      -&gt; pins and segments they control
//   ---------    ---------
//   |   A   |    |   A   |
//  F|       |B  F|       |B
//   |---G---|    |---G---|
//  E|       |C  E|       |C
//   |   D   |    |   D   |
//   ---------    ---------
//        |  |  |  |  |      -&gt; pins and segments they control
//        D  DP E  C CA2         

// Segments that make each number when lit:
// 0 =&gt; -FEDCBA
// 1 =&gt; ----BC-
// 2 =&gt; G-ED-BA
// 3 =&gt; G--DCBA
// 4 =&gt; GF--CB-
// 5 =&gt; GF-DC-A
// 6 =&gt; GFEDC-A
// 7 =&gt; ----CBA
// 8 =&gt; GFEDCBA
// 9 =&gt; GF-DCBA

// Arduino digital pins used to light up
// corresponding segments on the LED display
#define A 3
#define B 2
#define C 6
#define D 8
#define E 7
#define F 4
#define G 5

// Pins driving common anodes
#define CA1 13
#define CA2 12

// Pins for A B C D E F G, in sequence
const int segs[7] = { 3, 2, 6, 8, 7, 4, 5 };

// Segments that make each number
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010,
0b0000010, 0b1111000, 0b0000000, 0b0010000 };

void setup() {
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  pinMode(E, OUTPUT);
  pinMode(F, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(CA1, OUTPUT);
  pinMode(CA2, OUTPUT);
}

void loop() {
  for (int digit1=0; digit1 &lt; 10; digit1++) {
    for (int digit2=0; digit2 &lt; 10; digit2++) {
      unsigned long startTime = millis();
      for (unsigned long elapsed=0; elapsed &lt; 600; elapsed = millis() - startTime) {
        lightDigit1(numbers[digit1]);
        delay(5);
        lightDigit2(numbers[digit2]);
        delay(5);
      }
    }
  }
}

void lightDigit1(byte number) {
  digitalWrite(CA1, LOW);
  digitalWrite(CA2, HIGH);
  lightSegments(number);
}

void lightDigit2(byte number) {
  digitalWrite(CA1, HIGH);
  digitalWrite(CA2, LOW);
  lightSegments(number);
}

void lightSegments(byte number) {
  for (int i = 0; i &lt; 7; i++) {
    int bit = bitRead(number, i);
    digitalWrite(segs[i], bit);
  }
}</pre>
<p>Here&#8217;s a video of the <a href="http://www.youtube.com/watch?v=bEE9ouaXEbU" target="_blank">2-digit 7-segment display counter in action</a>.</p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-with-buttons/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display with Buttons'>Arduino 2-Digit 7-Segment Display with Buttons</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter-sketch/' rel='bookmark' title='Permanent Link: Arduino 2-Digit 7-Segment Display Counter: Sketch'>Arduino 2-Digit 7-Segment Display Counter: Sketch</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 4'>Controlling a Seven-Segment Display Using Arduino Part 4</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/02/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Permanent Link: Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/06/arduino-2-digit-7-segment-display-counter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino Mini: an Account of Coolness in 4 Links</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mini-an-account-of-coolness-in-4-links/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mini-an-account-of-coolness-in-4-links/#comments</comments>
		<pubDate>Tue, 25 May 2010 05:00:49 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[Mini]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=104</guid>
		<description><![CDATA[Pregnancy: a pregnancy belt that notifies the father every time the unborn baby kicks? Oh, and it tweets it: http://www.nydailynews.com/lifestyle/2008/12/17/2008-12-17_twittering_from_the_womb_how_soon_is_too.html UAV: Sean Reynolds achieves autonomous flight control with this Arduino-based unmanned aerial vehicle: http://seanreynoldscs.com/WashUAV.aspx Bluetooth: can&#8217;t afford a Bluetooth Arduino project? Check out this inexpensive Bluetooth module for the Arduino Mini: http://interactive.usc.edu/members/jbleecker/archives/007361.html Stribe: have you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4234&amp;affiliate_banner_id=1" target="_blank"><img class="alignright size-full wp-image-105" style="margin: 5px;" title="arduino-stamp" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/arduino-stamp.jpg" alt="Arduino Stamp Mini" width="200" height="178" /></a></p>
<ol>
<li><strong>Pregnancy</strong>: a pregnancy belt that notifies the father every time the unborn baby kicks? Oh, and it tweets it: <a href="http://www.nydailynews.com/lifestyle/2008/12/17/2008-12-17_twittering_from_the_womb_how_soon_is_too.html" target="_blank">http://www.nydailynews.com/lifestyle/2008/12/17/2008-12-17_twittering_from_the_womb_how_soon_is_too.html</a></li>
<li><strong>UAV</strong>: Sean Reynolds achieves autonomous flight control with this Arduino-based unmanned aerial vehicle: <a href="http://www.youtube.com/user/seanreynoldscs#p/a/u/2/RHUtRulf4OM" target="_blank">http://seanreynoldscs.com/WashUAV.aspx</a></li>
<li><strong>Bluetooth</strong>: can&#8217;t afford a Bluetooth Arduino project? Check out this inexpensive Bluetooth module for the Arduino Mini: http://interactive.usc.edu/members/jbleecker/archives/007361.html</li>
<li><strong>Stribe</strong>: have you heard of stribes? A stribe is a lighted touch strip music controller: <a href="http://stribe-org.blogspot.com/2008/01/description.html" target="_blank">http://stribe-org.blogspot.com/2008/01/description.html</a></li>
</ol>
<p><strong><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4234&amp;affiliate_banner_id=1" target="_blank">Buy the Arduino Stamp Mini</a></strong></p>
<p>The Mini at the official Arduino website: <a href="http://www.arduino.cc/en/Main/ArduinoBoardMini" target="_blank">http://www.arduino.cc/en/Main/ArduinoBoardMini</a></p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-lilypad-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Lilypad: an Account of Coolness in 4 Links'>Arduino Lilypad: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mega-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Mega: an Account of Coolness in 4 Links'>Arduino Mega: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-nano-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Nano: an Account of Coolness in 4 Links'>Arduino Nano: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/04/an-arduino-for-any-project/' rel='bookmark' title='Permanent Link: An Arduino for Any Project'>An Arduino for Any Project</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mini-an-account-of-coolness-in-4-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Nano: an Account of Coolness in 4 Links</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-nano-an-account-of-coolness-in-4-links/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-nano-an-account-of-coolness-in-4-links/#comments</comments>
		<pubDate>Tue, 18 May 2010 05:00:05 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[Nano]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=100</guid>
		<description><![CDATA[Light: how do you feel today? Find out with the interactive, multi-function mood light: http://www.instructables.com/id/Interactive-Open-Source-Mood-Light/ Sound: have you ever played with water filled crystal glasses to make sound? How about using an Arduino Nano to control the music? Check out this cool video: http://www.vimeo.com/1261369 Game: it&#8217;s no Wii, but this simple version of Super Mario [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4235&amp;affiliate_banner_id=1" target="_blank"><img class="alignright size-full wp-image-101" style="margin: 5px;" title="arduino-nano" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/arduino-nano.jpg" alt="Arduino Nano" width="167" height="200" /></a></p>
<ol>
<li><strong>Light</strong>: how do you feel today? Find out with the interactive, multi-function mood light: <a href="http://www.instructables.com/id/Interactive-Open-Source-Mood-Light/" target="_blank">http://www.instructables.com/id/Interactive-Open-Source-Mood-Light/</a></li>
<li><strong>Sound</strong>: have you ever played with water filled crystal glasses to make sound? How about using an Arduino Nano to control the music? Check out this cool video: <a href="http://www.vimeo.com/1261369" target="_blank">http://www.vimeo.com/1261369</a></li>
<li><strong>Game</strong>: it&#8217;s no Wii, but this simple version of Super Mario Bros using an 8&#215;8 LED matrix rocks: <a href="http://vimeo.com/9928343" target="_blank">http://vimeo.com/9928343</a></li>
<li><strong>iPod</strong>: an Arduino-based iPod remote with a single button that toggles between Play and Pause on the iPod: <a href="http://davidfindlay.org/weblog/files/2009_09_07_ipod_remote.php" target="_blank">http://davidfindlay.org/weblog/files/2009_09_07_ipod_remote.php</a></li>
</ol>
<p><strong><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4235&amp;affiliate_banner_id=1" target="_blank">Buy the Arduino Nano Ver 3.0</a></strong></p>
<p>The Nano at the official Arduino website: <a href="http://www.arduino.cc/en/Main/ArduinoBoardNano" target="_blank">http://www.arduino.cc/en/Main/ArduinoBoardNano</a></p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-lilypad-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Lilypad: an Account of Coolness in 4 Links'>Arduino Lilypad: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mini-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Mini: an Account of Coolness in 4 Links'>Arduino Mini: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mega-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Mega: an Account of Coolness in 4 Links'>Arduino Mega: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/04/an-arduino-for-any-project/' rel='bookmark' title='Permanent Link: An Arduino for Any Project'>An Arduino for Any Project</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-nano-an-account-of-coolness-in-4-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Lilypad: an Account of Coolness in 4 Links</title>
		<link>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-lilypad-an-account-of-coolness-in-4-links/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-lilypad-an-account-of-coolness-in-4-links/#comments</comments>
		<pubDate>Tue, 11 May 2010 05:00:11 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Lilypad]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=92</guid>
		<description><![CDATA[Jacket 1: a jacket with turn signals that lets people know where you&#8217;re headed when you&#8217;re on your bike: http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html Jacket 2: a jacket that both heats and cools based on one’s body temperature: http://www.instructables.com/id/How-to-make-a-Heating-and-Cooling-Jacket/ Shirt: this cool shirt features an RGB LED that changes color in response to motion and tilt: http://web.media.mit.edu/~leah/LilyPad/build/accelero_shirt.html Scarf: this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4233&amp;affiliate_banner_id=1" target="_blank"><img class="alignright size-full wp-image-93" style="margin: 5px;" title="arduino-lilypad" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/05/arduino-lilypad.jpg" alt="Arduino Lilypad" width="144" height="108" /></a></p>
<ol>
<li><strong>Jacket 1</strong>: a jacket with turn signals that lets people know where you&#8217;re headed when you&#8217;re on your bike: <a href="http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html" target="_blank">http://web.media.mit.edu/~leah/LilyPad/build/turn_signal_jacket.html</a></li>
<li><strong>Jacket 2</strong>: a jacket that both heats and cools based on one’s body temperature: <a href="http://www.instructables.com/id/How-to-make-a-Heating-and-Cooling-Jacket/" target="_blank">http://www.instructables.com/id/How-to-make-a-Heating-and-Cooling-Jacket/</a></li>
<li><strong>Shirt</strong>: this cool shirt features an RGB LED that changes color in response to motion and tilt: <a href="http://web.media.mit.edu/~leah/LilyPad/build/accelero_shirt.html" target="_blank">http://web.media.mit.edu/~leah/LilyPad/build/accelero_shirt.html</a></li>
<li><strong>Scarf</strong>: this is no ordinary scarf! The interactive passion sensing scarf detects the presence of another scarf wearer nearby and sets the color of an RGB LED to either blue (lonely) or red (passion): <a href="http://www.instructables.com/id/Arduino-Lilypad-Interactive-Passion-Sensing-Scarf/" target="_blank">http://www.instructables.com/id/Arduino-Lilypad-Interactive-Passion-Sensing-Scarf/</a></li>
</ol>
<p><strong><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4233&amp;affiliate_banner_id=1" target="_blank">Buy the LilyPad Arduino</a></strong></p>
<p>The Lilypad at the Official Arduino website: <a href="http://www.arduino.cc/en/Main/ArduinoBoardLilyPad" target="_blank">http://www.arduino.cc/en/Main/ArduinoBoardLilyPad</a></p>


<p>You might also enjoy:<ol><li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mini-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Mini: an Account of Coolness in 4 Links'>Arduino Mini: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-mega-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Mega: an Account of Coolness in 4 Links'>Arduino Mega: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2010/05/arduino-nano-an-account-of-coolness-in-4-links/' rel='bookmark' title='Permanent Link: Arduino Nano: an Account of Coolness in 4 Links'>Arduino Nano: an Account of Coolness in 4 Links</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/2009/12/check-out-the-arduino-contest-winners/' rel='bookmark' title='Permanent Link: Check Out the Arduino Contest Winners'>Check Out the Arduino Contest Winners</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/2010/05/arduino-lilypad-an-account-of-coolness-in-4-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
