<?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; Arduino</title>
	<atom:link href="http://www.theelectronicshobbyist.com/blog/category/arduino/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>LED Patterns Using DIP Switch and Arduino</title>
		<link>http://www.theelectronicshobbyist.com/blog/led-patterns-using-dip-switch-and-arduino/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/led-patterns-using-dip-switch-and-arduino/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 06:00:31 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[DIP switch]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=533</guid>
		<description><![CDATA[When I posted the “LED Control Using DIP Switch” sketch last year (a simple setup the turned on the LED corresponding to that switch position), I also had a slightly modified version of it in which the DIP switch controlled six different light patterns on the LEDs (scroll right, left, in, out, back and forth [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When I posted the “<a href="http://www.theelectronicshobbyist.com/blog/2010/09/arduino-led-control-using-dip-switch/">LED Control Using DIP Switch</a>” sketch last year (a simple setup the turned on the <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4215" target="_blank">LED</a> corresponding to that switch position), I also had a slightly modified version of it in which the <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4318" target="_blank">DIP switch</a> controlled six different light patterns on the LEDs (scroll right, left, in, out, back and forth and random). It presented a “cleaned-up” version of the code using <span style="font-family: 'Courier New';">for</span> loops and compared it to the “long-hand” version, showing the trade-off between ease of understanding and conciseness. Except that… I forgot to post it.</p>
<p>Last week someone contacted me asking a question about a similar project he is working on and when I wanted to refer him to this modified sketch I realized it wasn’t on the blog. (Here’s the <a href="http://www.theelectronicshobbyist.com/blog/2010/09/arduino-led-control-using-dip-switch/">original sketch</a> and <a href="http://www.theelectronicshobbyist.com/blog/2010/09/arduino-led-control-using-dip-switch-schematic/">schematic</a> for reference).<span id="more-533"></span></p>
<p>What follows below is the missing blog post (not anymore), a comparison between the more readable sketch (easier for beginners to understand) and the more concise version, in a series of snippets showing the main differences between the two versions of the sketch.</p>
<p>The concise version generates a binary sketch that occupies approximately 25% less memory and is almost half as long in lines of code. The entire source code listings are at the very bottom of this post.</p>
<p><em>Note: the line above each snippet reflects the modification that shortened the sketch.</em></p>
<p>1) not using <span style="font-family: 'Courier New';">#define</span> directives for the LED and switch pins on the <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4447" target="_blank">Arduino</a> in order to use <span style="font-family: 'Courier New';">for</span> loops:</p>
<table border="1">
<tbody>
<tr>
<td>
<pre>    } else {
     // default: off
     digitalWrite(LED1, LOW);
     digitalWrite(LED2, LOW);
     digitalWrite(LED3, LOW);
     digitalWrite(LED4, LOW);
     digitalWrite(LED5, LOW);
     digitalWrite(LED6, LOW);
   }</pre>
</td>
<td>
<pre>    } else {
     // default: off
     for (i = 13; i &gt;= 8; i--) {
       digitalWrite(i, LOW);
     }</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>2) using a state variable array (and consequently a <span style="font-family: 'Courier New';">for</span> loop) as opposed to individual state variables:</p>
<table border="1">
<tbody>
<tr>
<td>
<pre>   s1state = digitalRead(S1);
   s2state = digitalRead(S2);
   s3state = digitalRead(S3);
   s4state = digitalRead(S4);
   s5state = digitalRead(S5);
   s6state = digitalRead(S6);</pre>
</td>
<td>
<pre>   for (i = 0, j = 7; i &lt; 6, j &gt;= 2; i++, j--) {
     state[i] = digitalRead(j);
   }</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>3) <span style="font-family: 'Courier New';">if (x)</span> versus <span style="font-family: 'Courier New';">if (x == 1)</span> (when <span style="font-family: 'Courier New';">x</span> is either <span style="font-family: 'Courier New';">0</span> or <span style="font-family: 'Courier New';">1</span>, then the (<span style="font-family: 'Courier New';">x == 1)</span> expression can be written as simply (<span style="font-family: 'Courier New';">x</span>)):</p>
<table border="1">
<tbody>
<tr>
<td>
<pre>    } else if (s5state == 1) {
     // scroll back and forth</pre>
</td>
<td>
<pre>    } else if (state[4]) {
     // scroll back and forth</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>4) long, repetitive code to randomly turn on or not each LED (for a random duration up to 300 milliseconds) replaced with <span style="font-family: 'Courier New';">for</span> loop:</p>
<table border="1">
<tbody>
<tr>
<td>
<pre>    } else if (s6state == 1) {
     // random
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED1, onoroff);
     delay(millisecs);
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED2, onoroff);
     delay(millisecs);
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED3, onoroff);
     delay(millisecs);
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED4, onoroff);
     delay(millisecs);
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED5, onoroff);
     delay(millisecs);
     randomSeed(analogRead(3));
     onoroff = random(0, 2);
     millisecs = random(0, 301);
     digitalWrite(LED6, onoroff);
     delay(millisecs);
   }</pre>
</td>
<td>
<pre>    } else if (state[5]) {
     // random
     for (i = 13; i &gt;= 8; i--) {
       randomSeed(analogRead(i - 8));
       onoroff = random(0, 2);
       millisecs = random(0, 301);
       digitalWrite(i, onoroff);
       delay(millisecs);
     }
   }</pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Here’s the full long version:</p>
<ul>
<li>Binary sketch size: 3654 bytes</li>
<li>Code size was sacrificed in order to improve readability for beginners</li>
<li>Sketch length: 205 lines</li>
</ul>
<div style="width: 500px; height: 500px; overflow: auto; border: #cccccc 1px solid; padding: 5px;">
<pre>  // www.TheElectronicsHobbyist.com/blog
  // Natalia Fargasch Norman
  // LED control via DIP switches

  // <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> pins used for the LEDs
  #define LED1 13
  #define LED2 12
  #define LED3 11
  #define LED4 10
  #define LED5 9
  #define LED6 8

  // Arduino pins used for the switches
  #define S1 7
  #define S2 6
  #define S3 5
  #define S4 4
  #define S5 3
  #define S6 2

  // State of each switch (0 or 1)
  int s1state;
  int s2state;
  int s3state;
  int s4state;
  int s5state;
  int s6state;

  // Random values for LED state and delay
  long onoroff;
  long millisecs;

  void setup() {
    // pins for LEDs are outputs
    pinMode(LED1, OUTPUT);
    pinMode(LED2, OUTPUT);
    pinMode(LED3, OUTPUT);
    pinMode(LED4, OUTPUT);
    pinMode(LED5, OUTPUT);
    pinMode(LED6, OUTPUT);
    // pins for switches are inputs
    pinMode(S1, INPUT);
    pinMode(S2, INPUT);
    pinMode(S3, INPUT);
    pinMode(S4, INPUT);
    pinMode(S5, INPUT);
    pinMode(S6, INPUT);
  }

  void loop() {
    s1state = digitalRead(S1);
    s2state = digitalRead(S2);
    s3state = digitalRead(S3);
    s4state = digitalRead(S4);
    s5state = digitalRead(S5);
    s6state = digitalRead(S6);
    if (s1state == 1) {
      // scroll right
      digitalWrite(LED1, HIGH);
      delay(250);
      digitalWrite(LED1, LOW);
      digitalWrite(LED2, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
      digitalWrite(LED3, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED4, LOW);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED5, LOW);
      digitalWrite(LED6, HIGH);
      delay(250);
      digitalWrite(LED6, LOW);
    } else if (s2state == 1) {
      // scroll left
      digitalWrite(LED6, HIGH);
      delay(250);
      digitalWrite(LED6, LOW);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED5, LOW);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED4, LOW);
      digitalWrite(LED3, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED2, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
      digitalWrite(LED1, HIGH);
      delay(250);
      digitalWrite(LED1, LOW);
    } else if (s3state == 1) {
      // scroll in
      digitalWrite(LED1, HIGH);
      digitalWrite(LED6, HIGH);
      delay(250);
      digitalWrite(LED1, LOW);
      digitalWrite(LED6, LOW);
      digitalWrite(LED2, HIGH);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
      digitalWrite(LED5, LOW);
      digitalWrite(LED3, HIGH);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED4, LOW);
    } else if (s4state == 1) {
      // scroll out
      digitalWrite(LED3, HIGH);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED4, LOW);
      digitalWrite(LED2, HIGH);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
      digitalWrite(LED5, LOW);
      digitalWrite(LED1, HIGH);
      digitalWrite(LED6, HIGH);
      delay(250);
      digitalWrite(LED1, LOW);
      digitalWrite(LED6, LOW);
    } else if (s5state == 1) {
      // scroll back and forth
      digitalWrite(LED1, HIGH);
      delay(250);
      digitalWrite(LED1, LOW);
      digitalWrite(LED2, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
      digitalWrite(LED3, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED4, LOW);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED5, LOW);
      digitalWrite(LED6, HIGH);
      delay(250);
      digitalWrite(LED6, LOW);
      digitalWrite(LED5, HIGH);
      delay(250);
      digitalWrite(LED5, LOW);
      digitalWrite(LED4, HIGH);
      delay(250);
      digitalWrite(LED4, LOW);
      digitalWrite(LED3, HIGH);
      delay(250);
      digitalWrite(LED3, LOW);
      digitalWrite(LED2, HIGH);
      delay(250);
      digitalWrite(LED2, LOW);
    } else if (s6state == 1) {
      // random
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED1, onoroff);
      delay(millisecs);
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED2, onoroff);
      delay(millisecs);
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED3, onoroff);
      delay(millisecs);
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED4, onoroff);
      delay(millisecs);
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED5, onoroff);
      delay(millisecs);
      randomSeed(analogRead(3));
      onoroff = random(0, 2);
      millisecs = random(0, 301);
      digitalWrite(LED6, onoroff);
      delay(millisecs);
    } else {
      // default: off
      digitalWrite(LED1, LOW);
      digitalWrite(LED2, LOW);
      digitalWrite(LED3, LOW);
      digitalWrite(LED4, LOW);
      digitalWrite(LED5, LOW);
      digitalWrite(LED6, LOW);
    }
  }</pre>
</div>
<p>&nbsp;</p>
<p>And here’s the full &#8220;cleaned-up&#8221; version:</p>
<ul>
<li>Binary sketch size: 2826 bytes</li>
<li>Sketch length: 119 lines</li>
</ul>
<div style="width: 500px; height: 500px; overflow: auto; border: #cccccc 1px solid; padding: 5px;">
<pre>  // www.TheElectronicsHobbyist.com/blog
  // Natalia Fargasch Norman
  // LED control via DIP switches

  // Arduino pins used for the LEDs
  // LED1 13
  // LED2 12
  // LED3 11
  // LED4 10
  // LED5 9
  // LED6 8

  // Arduino pins used for the switches
  // S1 7
  // S2 6
  // S3 5
  // S4 4
  // S5 3
  // S6 2

  // State of each switch (0 or 1)
  int state[6];

  // Random values for LED state and delay
  long onoroff;
  long millisecs;

  // loop counters
  int i, j;

  // delay
  int d = 250;

  void setup() {
    // pins for LEDs are outputs
    // LEDs 1-6 on pins 13-8
    for (i = 13; i &gt;= 8; i--) {
      pinMode(i, OUTPUT);
    }
    // pins for switches are inputs
    // switches 1-6 on pins 7-2
    for (i = 7; i &gt;= 2; i--) {
      pinMode(i, INPUT);
    }
  }

  void loop() {
    for (i = 0, j = 7; i &lt; 6, j &gt;= 2; i++, j--) {
      state[i] = digitalRead(j);
    }

    if (state[0]) {
      // scroll right
      for (i = 13; i &gt;= 8; i--) {
        digitalWrite(i, HIGH);
        delay(d);
        digitalWrite(i, LOW);
      }

    } else if (state[1]) {
      // scroll left
      for (i = 8; i &lt;= 13; i++) {
         digitalWrite(i, HIGH);
         delay(d);
         digitalWrite(i, LOW);
       }

   } else if (state[2]) {
       // scroll in
       // light up LEDs on pins i and 8+(13-i)
       for (i = 13; i &gt;= 11; i--) {
        digitalWrite(i, HIGH);
        digitalWrite(21 - i, HIGH);
        delay(d);
        digitalWrite(i, LOW);
        digitalWrite(21 - i, LOW);
      }

    } else if (state[3]) {
      // scroll out
      // light up LEDs on pins i and 8+(13-i)
      for (i = 11; i &lt;= 13; i++) {
         digitalWrite(i, HIGH);
         digitalWrite(21 - i, HIGH);
         delay(d);
         digitalWrite(i, LOW);
         digitalWrite(21 - i, LOW);
       }

    } else if (state[4]) {
       // scroll back and forth
       for (i = 13; i &gt;= 8; i--) {
        digitalWrite(i, HIGH);
        delay(d);
        digitalWrite(i, LOW);
      }
      for (i = 9; i &lt;= 12; i++) {
        digitalWrite(i, HIGH);
        delay(d);
        digitalWrite(i, LOW);
      }

    } else if (state[5]) {
       // random
       for (i = 13; i &gt;= 8; i--) {
        randomSeed(analogRead(i - 8));
        onoroff = random(0, 2);
        millisecs = random(0, 301);
        digitalWrite(i, onoroff);
        delay(millisecs);
      }      

    } else {
      // default: off
      for (i = 13; i &gt;= 8; i--) {
        digitalWrite(i, LOW);
      }
    }
  }</pre>
</div>
<p>Check out the <a href="http://www.youtube.com/watch?v=fHVdCT-iZwk" target="_blank">video</a> of this sketch in action.</p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch/' rel='bookmark' title='Arduino LED Control Using DIP Switch | Part 1'>Arduino LED Control Using DIP Switch | Part 1</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</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-2-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 2'>Controlling a Seven-Segment Display Using Arduino Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/led-patterns-using-dip-switch-and-arduino/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino Serial Display: Introducing the GLO-216 2&#215;16 Multifont Serial OLED Display</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-serial-display-introducing-the-glo-216-2x16-multifont-serial-oled-display/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-serial-display-introducing-the-glo-216-2x16-multifont-serial-oled-display/#comments</comments>
		<pubDate>Tue, 31 May 2011 20:00:28 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[OLED]]></category>
		<category><![CDATA[OLED display]]></category>
		<category><![CDATA[sketch]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=475</guid>
		<description><![CDATA[The GLO-216 2&#215;16 Multifont Serial OLED allows you to translate 9600bps serial data into bright, high-contrast text on a compact screen. This low cost, low power serial display comes in two font colors (yellow and green) and is made and sold by seetron.com, owned by Scott Edwards of Electronics Now and Nuts &#38; Volts fame. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://seetron.com/glo216.html" target="_blank"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="size-medium wp-image-479 alignleft" title="imglo" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/05/imglo-300x225.jpg" alt="GLO216 Serial OLED Display" width="300" height="225" /></a>The <a href="http://seetron.com/glo216.html" target="_blank">GLO-216 2&#215;16 Multifont Serial OLED</a> allows you to translate 9600bps serial data into bright, high-contrast text on a compact screen. This low cost, low power serial display comes in two font colors (yellow and green) and is made and sold by <a href="http://seetron.com" target="_blank">seetron.com</a>, owned by Scott Edwards of Electronics Now and Nuts &amp; Volts fame.</p>
<p>Think of the <a href="http://seetron.com/glo216.html" target="_blank">GLO-216</a> as a &#8220;mini terminal&#8221; that displays text and custom characters and responds to control characters such as tabs, linefeeds, carriage returns, backspace, etc. It is compatible with RS-232, Stamps, PICs and Arduino; pretty much any serial out, really.</p>
<p>The display uses less than 50mA, so it can be connected straight to the Arduino&#8217;s power supply.<span id="more-475"></span></p>
<p>The GLO-216 can store startup text and custom characters in EEPROM and there are instructions to save and recall this information. The simple sketch created to test the display creates and saves a new heart shaped custom character, then displays it on the screen along with some text.</p>
<blockquote><p>Seetron.com has set up a special offer for theelectronicshobbyist.com/blog readers: you can <strong>save 20% off a GLO-216</strong> if you use promo code &#8220;<strong>HOBBYIST</strong>&#8221; upon check out. For more information and to purchase, see the <a href="http://seetron.com/glo216.html" target="_blank">GLO-216 product page</a>.</p></blockquote>
<p style="text-align: left;">Here&#8217;s the GLO-216G just out of the box:<br />
<a href="http://seetron.com/glo216.html" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-480" title="glo216gfront" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/05/glo216gfront-300x225.jpg" alt="GLO216 OLED display front" width="300" height="225" /></a><br />
And here&#8217;s the view from the back, notice the small board that brings out the pins nicely to a 5-pin header and saves you some soldering work:<br />
<a href="http://seetron.com/glo216.html" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-481" title="glo216gback" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/05/glo216gback-300x225.jpg" alt="GLO216 OLED display back" width="300" height="225" /></a><br />
This is what it looks like when you first power it on:<br />
<a href="http://seetron.com/glo216.html" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-482" title="glo216gseetron" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/05/glo216gseetron-300x225.jpg" alt="GLO216 Serial OLED Display by seetron" width="300" height="225" /></a><br />
And here&#8217;s the result of running the sketch I included in this post, that defines and prints a custom character:<br />
<a href="http://seetron.com/glo216.html" target="_blank"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-medium wp-image-483" title="higlo" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2011/05/higlo-300x225.jpg" alt="GLO216 Serial OLED Display custom character" width="300" height="225" /></a></p>
<p>The sketch to drive the display uses the &#8220;newsoftserial&#8221; library, which can be found here: <a href="http://arduiniana.org/libraries/newsoftserial" target="_blank">http://arduiniana.org/libraries/newsoftserial</a></p>
<p>A few nice features of the newsoftserial library compared to the original softserial are more accurate timing, smaller code size, but best of all the ability to output &#8220;inverted&#8221; serial (the <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> documentation states that their serial output is not RS-232 compatible, but newsoftserial permits the <a href="http://www.theelectronicshobbyist.com/blog/goto/uno">Arduino</a> to output inverted serial).</p>
<p>Sketch:</p>
<div style="width: 550px; height: 500px; overflow: auto; padding: 5px; border: 1px solid #CCCCCC;">
<pre>// Test of the GLO-216G serial OLED display
// Natalia Fargasch Norman @ theelectronicshobbyist.com/blog

// GLO-216Y/G information: http://www.seetron.com/glo216.html
// Programming reference: http://seetron.com/glo216/glo216prog.html

#include &lt;SoftwareSerial.h&gt;
#include &lt;GLO216.h&gt;

#define rxPin 255
#define txPin 3
#define NULL 0x00

int inverted = 1;

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin, inverted);

void setup() {
  pinMode(txPin, OUTPUT);
  digitalWrite(txPin, LOW);
  mySerial.begin(9600);
  delay(10);

  // clears the screen and select font size and style
  char instr1[] = {
    clearScreen(),
    defaultSize(),
    selectSize(), // tall
    selectSize(), // wide
    selectSize(), // big
    textStyle(),
    NULL
  };
  const char message[] = "Hi GLO!";
  mySerial.print(instr1);
  // print message according to prior instructions
  mySerial.print(message);

  // defines a new custom heart shaped character
  char instr2[] = {
    // escape sequence to receive new custom character
    escape(),'D','0',
    // heart pattern using tool at http://seetron.com/apps/app_cceditor.html
    0x80,0x8A,0x95,0x91,0x8A,0x84,0x80,0x80,
    NULL
  };
  // print character 0x80, the newly defined heart
  const char msg[] = {0x80, NULL};
  mySerial.print(instr2);
  // print message according to prior instructions
  mySerial.print(msg);

/*  delay(3000);

  char instr3[] = {
    clearScreen(),
    NULL
  };
  mySerial.print(instr3);*/
}

void loop() {
  // ...
}</pre>
</div>
<p>GLO216 functions:</p>
<div style="width: 550px; height: 500px; overflow: auto; padding: 5px; border: 1px solid #CCCCCC;">
<pre>// GLO-216G serial OLED display
// Natalia Fargasch Norman @ theelectronicshobbyist.com/blog

// GLO-216Y/G information: http://www.seetron.com/glo216.html
// Programming reference: http://seetron.com/glo216/glo216prog.html

/*
Parameters for setPosition and rightAlign instructions:
setPosition: position + 0x40
rightAlign: '0'-'7'
*/

/*
Parameters for escape instructions:
Define lower custom character: 'D', '0'-'7'
Define upper custom character: 'd', '0'-'7'
Recall saved text: 'E', '0'
Restore custom character set: 'e', '0'
Save text since last clearScreen: 'X', '0'
Store custom character set: 'x', '0'
*/

// Moves printing position to the first character of top line
char homeCursor() {
  return 0x01;
}

// Cycles the font size: normal -&gt; tall -&gt; wide -&gt; big -&gt; normal -&gt; ...
char selectSize() {
  return 0x02;
}

// Sets font size to default of small on two lines of 16 characters
char defaultSize() {
  return 0x03;
}

// Behaves like the backspace key
char backspace() {
  return 0x08;
}

// Moves printing position to the next multiple of 4 location
char tab() {
  return 0x09;
}

// Moves the printing position down a line
char linefeed() {
  return 0x0A;
}

// Moves the printing position up a line
char verticalTab() {
  return 0x0B;
}

// Clears the screen and moves printing position to 0
char clearScreen() {
  return 0x0C;
}

// Moves to the first printing position of the next line
char carriageReturn() {
  return 0x0D;
}

// Turns on the OLED driver circuitry when it has been previously turned off
char turnOn() {
  return 0x0E;
}

// Turns off the OLED driver circuitry to save power
char turnOff() {
  return 0x0F;
}

// Sets the printing position according to value of next byte
char setPosition() {
  return 0x10;
}

// Prints text at the righthand end of a field of defined size from 2-8
char rightAlign() {
  return 0x12;
}

// Sets seven segment style font for large characters
char sevenSeg() {
  return 0x13;
}

// Sets text style font for large characters
char textStyle() {
  return 0x14;
}

// Begin multi-part instruction
char escape() {
  return 0x1B;
}

// See http://seetron.com/glo216/bpigloupgg.html
char bpkInstr() {
  return 0xFE;
}</pre>
</div>
<p>Header file:</p>
<div style="width: 550px; height: 200px; overflow: auto; padding: 5px; border: 1px solid #CCCCCC;">
<pre>// GLO-216G serial OLED display
// Natalia Fargasch Norman @ theelectronicshobbyist.com/blog

// GLO-216Y/G information: http://www.seetron.com/glo216.html
// Programming reference: http://seetron.com/glo216/glo216prog.html

#ifndef GLO216_h
#define GLO216_h

// Moves printing position to the first character of top line
char homeCursor();

// Cycles the font size: normal -&gt; tall -&gt; wide -&gt; big -&gt; normal -&gt; ...
char selectSize();

// Sets font size to default of small on two lines of 16 characters
char defaultSize();

// Behaves like the backspace key
char backspace();

// Moves printing position to the next multiple of 4 location
char tab();

// Moves the printing position down a line
char linefeed();

// Moves the printing position up a line
char verticalTab();

// Clears the screen and moves printing position to 0
char clearScreen();

// Moves to the first printing position of the next line
char carriageReturn();

// Turns on the OLED driver circuitry when it has been previously turned off
char turnOn();

// Turns off the OLED driver circuitry to save power
char turnOff();

// Sets the printing position according to value of next byte
char setPosition();

// Prints text at the righthand end of a field of defined size from 2-8
char rightAlign();

// Sets seven segment style font for large characters
char sevenSeg();

// Sets text style font for large characters
char textStyle();

// Begin multi-part instruction
char escape();

// See http://seetron.com/glo216/bpigloupgg.html
char bpkInstr();

#endif</pre>
</div>
<p>Keywords file:</p>
<div style="width: 550px; height: 200px; overflow: auto; padding: 5px; border: 1px solid #CCCCCC;">
<pre>#######################################
# Syntax Coloring Map for GLO216
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

GLO216	KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

homeCursor	KEYWORD2
selectSize	KEYWORD2
defaultSize	KEYWORD2
backspace	KEYWORD2
tab	KEYWORD2
linefeed	KEYWORD2
verticalTab	KEYWORD2
clearScreen	KEYWORD2
carriageReturn	KEYWORD2
turnOn	KEYWORD2
turnOff	KEYWORD2
setPosition	KEYWORD2
rightAlign	KEYWORD2
sevenSeg	KEYWORD2
textStyle	KEYWORD2
escape	KEYWORD2
bpkInstr	KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################</pre>
</div>
<p>Download these four files in an archive here: <a href="http://www.theelectronicshobbyist.com/docs/GLO216.zip" target="_blank">GLO216.zip</a></p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-serial-communication/' rel='bookmark' title='Arduino Serial Communication'>Arduino Serial Communication</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/led-patterns-using-dip-switch-and-arduino/' rel='bookmark' title='LED Patterns Using DIP Switch and Arduino'>LED Patterns Using DIP Switch and Arduino</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-2-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 2'>Controlling a Seven-Segment Display Using Arduino Part 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-serial-display-introducing-the-glo-216-2x16-multifont-serial-oled-display/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino LED Control Using DIP Switch &#124; Part 1</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 05:00:48 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[DIP switch]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[pins]]></category>
		<category><![CDATA[serial communication]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=356</guid>
		<description><![CDATA[This is a very simple project that controls a set of LEDs using a DIP switch. The purpose of the sketch is to show the use of some Arduino serial communication functions, and to increase familiarity interfacing with digital I/O pins. Two LEDs were connected to the RX and TX pins on the Arduino (digital [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/09/dipleds.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-medium wp-image-357" title="dipleds" src="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/09/dipleds-234x300.jpg" alt="LED control using DIP switch" width="234" height="300" /></a>This is a very simple project that controls a set of LEDs using a DIP switch. The purpose of the sketch is to show the use of some <a href="http://www.theelectronicshobbyist.com/blog/2010/08/arduino-serial-communication/" target="_self">Arduino serial communication</a> functions, and to increase familiarity interfacing with digital I/O pins.</p>
<p>Two LEDs were connected to the RX and TX pins on the Arduino (digital pins 0 and 1), but remember to disconnect these pins while the sketch is being uploaded.</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=4304&amp;affiliate_banner_id=1" target="_blank">Breadboard</a></li>
<li>8 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4215&amp;affiliate_banner_id=1" target="_blank">LEDs</a>, assorted colors</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 wire, assorted lengths</a></li>
<li><a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4318&amp;affiliate_banner_id=1" target="_blank">DIP switch</a></li>
<li>6 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4383&amp;affiliate_banner_id=1" target="_blank">10K Ohm resistors</a> (pull up)</li>
<li>8 <a href="http://www.cutedigi.com/product_info.php?ref=3&amp;products_id=4373&amp;affiliate_banner_id=1" target="_blank">100 Ohm resistors</a> (current limiting)</li>
</ul>
<p><span id="more-356"></span></p>
<p>Sketch:</p>
<pre>// www.TheElectronicsHobbyist.com/blog
// Natalia Fargasch Norman
// LED control via DIP switches

// Arduino pins used for the LEDs
#define LED1 13
#define LED2 12
#define LED3 11
#define LED4 10
#define LED5 9
#define LED6 8

// <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> pins used for the switches
#define S1 7
#define S2 6
#define S3 5
#define S4 4
#define S5 3
#define S6 2

// State of each switch (0 or 1)
int s1state;
int s2state;
int s3state;
int s4state;
int s5state;
int s6state;

void setup() {
  // pins for LEDs are outputs
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
  // pins for switches are inputs
  pinMode(S1, INPUT);
  pinMode(S2, INPUT);
  pinMode(S3, INPUT);
  pinMode(S4, INPUT);
  pinMode(S5, INPUT);
  pinMode(S6, INPUT);
  // setup serial port
  Serial.begin(9600);
  Serial.println("Serial port open");
}

void loop() {
  s1state = digitalRead(S1);
  digitalWrite(LED1, s1state);
  s2state = digitalRead(S2);
  digitalWrite(LED2, s2state);
  s3state = digitalRead(S3);
  digitalWrite(LED3, s3state);
  s4state = digitalRead(S4);
  digitalWrite(LED4, s4state);
  s5state = digitalRead(S5);
  digitalWrite(LED5, s5state);
  s6state = digitalRead(S6);
  digitalWrite(LED6, s6state);
  Serial.print(s1state);
  Serial.print(s2state);
  Serial.print(s3state);
  Serial.print(s4state);
  Serial.print(s5state);
  Serial.print(s6state);
  Serial.println();
}</pre>
<p>A <a href="http://www.youtube.com/watch?v=SVVMeKMTtH8" target="_blank">video</a> of the project in action.</p>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/led-patterns-using-dip-switch-and-arduino/' rel='bookmark' title='LED Patterns Using DIP Switch and Arduino'>LED Patterns Using DIP Switch and Arduino</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino Part 3</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='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/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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arduino Serial Communication</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-serial-communication/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-serial-communication/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 09:00:06 +0000</pubDate>
		<dc:creator>Natalia</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[serial]]></category>

		<guid isPermaLink="false">http://www.theelectronicshobbyist.com/blog/?p=347</guid>
		<description><![CDATA[Computers can exchange bits of information serially (one after another, in sequence) or in parallel (several at the same time). In applications where it is necessary to have one computer talk to another, the most commonly used communication method is serial. So it is no surprise that serial communication is the method used to send [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Computers can exchange bits of information serially (one after another, in sequence) or in parallel (several at the same time). In applications where it is necessary to have one computer talk to another, the most commonly used communication method is serial.</p>
<p>So it is no surprise that serial communication is the method used to send data between the Arduino board and a computer (or other device). Information is sent to and from the computer and the Arduino by setting a pin high or low. One side sets the pin and the other reads it.</p>
<p>The Arduino <a href="http://www.theelectronicshobbyist.com/blog/goto/duemilanove" style="" target="_blank" rel="nofollow" onmouseover="self.status='http://www.theelectronicshobbyist.com/blog/goto/duemilanove';return true;" onmouseout="self.status=''">Duemilanove</a> has one serial port that communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. When you use the IDE to Upload your sketches to the Arduino, the bits are transmitted one at a time through the USB cable to the Arduino. The serial connection can also be used in our sketches to send data to the computer and to receive data from the computer via the serial monitor available on the IDE. This proves very useful for debugging your projects, as we will explore in the upcoming posts.<br />
<span id="more-347"></span><br />
The <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> serial library makes the following functions available for use in your sketches:</p>
<ul>
<li><span style="font-size: small;">begin(): opens serial port and sets the rate for serial data transmission (the RX and TX pins cannot be used for general input and output when the serial port is being used)</span></li>
<li><span style="font-size: small;">end(): disables serial communication (this allows the RX and TX pins to be used for general input and output again)</span></li>
<li><span style="font-size: small;">int available(): gets the number of bytes stored in the serial receive buffer (the buffer holds 128 bytes) that are available for reading from the serial port</span></li>
<li><span style="font-size: small;">int read(): reads incoming serial data</span></li>
<li><span style="font-size: small;">flush(): flushes the serial receive buffer of incoming serial data</span></li>
<li><span style="font-size: small;">print(): prints data to the serial port as human-readable ASCII text</span></li>
<li><span style="font-size: small;">println(): prints data to the serial port as human-readable ASCII text followed by a carriage return character and a newline character</span></li>
<li><span style="font-size: small;">write(): writes binary data to the serial port</span></li>
</ul>
<p>You might also enjoy:<ol>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-serial-display-introducing-the-glo-216-2x16-multifont-serial-oled-display/' rel='bookmark' title='Arduino Serial Display: Introducing the GLO-216 2&#215;16 Multifont Serial OLED Display'>Arduino Serial Display: Introducing the GLO-216 2&#215;16 Multifont Serial OLED Display</a></li>
<li><a href='http://www.theelectronicshobbyist.com/blog/arduino-led-control-using-dip-switch/' rel='bookmark' title='Arduino LED Control Using DIP Switch | Part 1'>Arduino LED Control Using DIP Switch | Part 1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-serial-communication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino RGB LED Control for the Spinning Night Light &#124; Part 4</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-control-spinning-night-light/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-control-spinning-night-light/#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></p><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:<br />
<span id="more-334"></span><br />
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 style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  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 <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> 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 < 256; i++) {
    analogWrite(RED, 255-i);
    analogWrite(GREEN, i);
    analogWrite(BLUE, 0);
    delay(50);
  }

  // fade from magenta to aqua
  for (int i = 0; i < 256; i++) {
    analogWrite(RED, i);
    analogWrite(GREEN, 255-i);
    analogWrite(BLUE, 0);
    delay(50);
  }
</pre>
<p>Here's the <a href="http://www.theelectronicshobbyist.com/blog/2010/07/arduino-rgb-led-spinning-night-light/">full sketch for the night light</a>.</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-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-led-control-using-dip-switch/' rel='bookmark' title='Arduino LED Control Using DIP Switch | Part 1'>Arduino LED Control Using DIP Switch | Part 1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-control-spinning-night-light/feed/</wfw:commentRss>
		<slash:comments>0</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 RGB LED Spinning Night Light &#124; Part 1</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-rgb-led-spinning-night-light/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/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>
		<category><![CDATA[video]]></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></p><p><a href="http://www.theelectronicshobbyist.com/blog/wp-content/uploads/2010/07/arduino-rgb-nightlight.jpg"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  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 <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> to control a <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> 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 <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">DC 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> 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.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">DC 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></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=Squid744799-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001AMWN1Q">147 Ohm Resistor</a></li>
<li><a href="http://www.amazon.com/gp/product/B0017KDZ4A?ie=UTF8&amp;tag=Squid744799-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0017KDZ4A">82 Ohm Resistor</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_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 < 256; i++) {
    analogWrite(RED, 255-i);
    analogWrite(GREEN, i);
    analogWrite(BLUE, 0);
    delay(50);
  }

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

}</pre>
<p>You might also enjoy:<ol>
<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-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-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/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='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/arduino-rgb-led-spinning-night-light/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display with Buttons: Sketch &#124; Part 5</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-with-buttons-sketch/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/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></p><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/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-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/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-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-2-digit-7-segment-display-with-buttons-sketch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arduino 2-Digit 7-Segment Display with Buttons &#124; Part 4</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-with-buttons/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/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></p><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 style=' display: block; margin-right: auto; margin-left: auto;'  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] = { A, B, C, D, E, F, G };

// 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 <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> <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/controlling-a-seven-segment-display-using-arduino-part-3-of-4/' rel='bookmark' title='Controlling a Seven-Segment Display Using Arduino Part 3'>Controlling a Seven-Segment Display Using Arduino 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/controlling-a-seven-segment-display-using-arduino-part-4-of-4/' rel='bookmark' title='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/arduino-2-digit-7-segment-display-with-buttons-sketch/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display with Buttons: Sketch | Part 5'>Arduino 2-Digit 7-Segment Display with Buttons: Sketch | Part 5</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.theelectronicshobbyist.com/blog/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 &#124; Part 3</title>
		<link>http://www.theelectronicshobbyist.com/blog/arduino-2-digit-7-segment-display-counter-sketch/</link>
		<comments>http://www.theelectronicshobbyist.com/blog/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></p><p>This is part 3 in the project to control a 2-digit 7-segment display using an <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>. 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/arduino-2-digit-7-segment-display-with-buttons-sketch/' rel='bookmark' title='Arduino 2-Digit 7-Segment Display with Buttons: Sketch | Part 5'>Arduino 2-Digit 7-Segment Display with Buttons: Sketch | Part 5</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/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-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 &#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 21:35:00 -->
