<?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>Limina.Log &#187; arduino</title>
	<atom:link href="http://log.liminastudio.com/tag/arduino/feed" rel="self" type="application/rss+xml" />
	<link>http://log.liminastudio.com</link>
	<description>Research &#38; Development at Limina.Studio</description>
	<lastBuildDate>Sun, 15 Jan 2012 21:25:34 +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>Getting started with the RN-XV WiFi Module &amp; Node.js</title>
		<link>http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js</link>
		<comments>http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js#comments</comments>
		<pubDate>Thu, 08 Dec 2011 04:08:54 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Sockets]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=951</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js' addthis:title='Getting started with the RN-XV WiFi Module &#38; Node.js '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The RN-XV WiFi module is a nifty little WiFi module designed to fit the same pinout as an XBee, so it&#8217;s intended to be a drop-in replacement. Tonight I whipped up a little test of the module to get a joystick to talk to a Node.js server over WiFi.  I attached +3V power and ground [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js' addthis:title='Getting started with the RN-XV WiFi Module &amp; Node.js '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The <a href="http://www.sparkfun.com/products/10822">RN-XV WiFi module</a> is a nifty little WiFi module designed to fit the same pinout as an XBee, so it&#8217;s intended to be a drop-in replacement.</p>
<p>Tonight I whipped up a little test of the module to get <a href="http://www.sparkfun.com/products/9032">a joystick</a> to talk to a <a href="http://nodejs.org/">Node.js</a> server over WiFi.  I attached +3V power and ground to the module (pins 1 and 10, respectively), pin 2 (TX) to Arduino digital pin 0 (RX), and pin 1 (RX) to Arduino digital pin 1 (TX).  That&#8217;s all the hardware setup you need.</p>
<p>I used <a href="https://github.com/jcrouchley/WiFly-Shield">this WiFly library</a> to handle the connection.  All it does is talk to the WiFly module over serial and send control commands, so the library abstracts that a bit.  Here&#8217;s the Arduino sketch I built:<span id="more-951"></span></p>
<pre>#include "WiFly.h"

#define PIN_VERT      0  // analog
#define PIN_HOR       1  // analog

#define PIN_PUSH      2
#define PIN_LED_RED   3
#define PIN_LED_GRN   4

int vert = 0;
int hor = 0;
bool push;

char* ssid = "yourNetwork";
char* pass = "yourPassword";

char* serverAddress = "yourServer";
int serverPort = 1337;

Client client(serverAddress, serverPort);

void setup(){
  pinMode(PIN_PUSH, INPUT);
  pinMode(PIN_LED_RED, OUTPUT);
  pinMode(PIN_LED_GRN, OUTPUT);

  digitalWrite(PIN_PUSH, HIGH);    // set pull-up resistor
  digitalWrite(PIN_LED_RED, LOW);  // start off
  digitalWrite(PIN_LED_GRN, LOW);

  Serial.begin(9600);
  WiFly.setUart(&amp;Serial);
  WiFly.begin();

  if (!WiFly.join(ssid, pass, true)) {
    digitalWrite(PIN_LED_RED, HIGH);
    while (1) {
      // Hang on failure.
    }
  }

  digitalWrite(PIN_LED_GRN, HIGH);

  if (client.connect()) {
    client.println("ohai!");
    client.println();
  } else {
    // do nothing
  }
}

void loop(){
  vert = analogRead(PIN_VERT);
  hor = analogRead(PIN_HOR);
  push = digitalRead(PIN_PUSH);

  digitalWrite(PIN_LED_RED, !push);

  client.print(vert);
  client.print('\t');
  client.print(hor);
  client.print('\t');
  client.print(push);
  client.println();
  delay(10);
}</pre>
<p>And here&#8217;s the very basic Node.js server that just prints out the values it receives:</p>
<pre>var net = require('net');

var server = net.createServer(function(socket) { //'connection' listener
	console.log('server connected');

	socket.setEncoding('ascii');

	socket.on('end', function() {
		console.log('server disconnected');
	});

	socket.on('data', function(data){
		console.log(data);
	});
});

server.listen(1337, function() { //'listening' listener
	console.log('server bound');
});</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Arduino Serial.print sends numbers instead of letters</title>
		<link>http://log.liminastudio.com/itp/physical-computing/arduino-serial-print-sends-numbers-instead-of-letters</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/arduino-serial-print-sends-numbers-instead-of-letters#comments</comments>
		<pubDate>Wed, 12 Oct 2011 03:04:49 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=934</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/arduino-serial-print-sends-numbers-instead-of-letters' addthis:title='Arduino Serial.print sends numbers instead of letters '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Recently I experienced a somewhat baffling, unexpected problem. I was using a line like: Serial.println('test'); And getting a series of numbers like 25536 instead of the expected text. It turned out the problem was just the use of the &#8216; instead of a &#8220;. Sigh.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/arduino-serial-print-sends-numbers-instead-of-letters' addthis:title='Arduino Serial.print sends numbers instead of letters '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Recently I experienced a somewhat baffling, unexpected problem. I was using a line like:</p>
<pre>Serial.println('test');</pre>
<p>And getting a series of numbers like 25536 instead of the expected text.  It turned out the problem was just the use of the &#8216; instead of a &#8220;.  Sigh.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/arduino-serial-print-sends-numbers-instead-of-letters/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AVRdude Verification Error Solution</title>
		<link>http://log.liminastudio.com/itp/physical-computing/avrdude-verification-error-solution</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/avrdude-verification-error-solution#comments</comments>
		<pubDate>Wed, 12 Oct 2011 02:22:48 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[avrdude]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=931</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/avrdude-verification-error-solution' addthis:title='AVRdude Verification Error Solution '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you&#8217;ve been getting an Arduino error like this: avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0007 0xff != 0x7f avrdude: verification error; content mismatch It may be as simple a fix as moving your USB cable from a hub directly to your computer—that fixed it for me! More information: I had [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/avrdude-verification-error-solution' addthis:title='AVRdude Verification Error Solution '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you&#8217;ve been getting an Arduino error like this:</p>
<pre>avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0007
         0xff != 0x7f
avrdude: verification error; content mismatch</pre>
<p>It may be as simple a fix as moving your USB cable from a hub directly to your computer—that fixed it for me!</p>
<p>More information: I had also been getting errors like this from avrdude:</p>
<pre>avrdude: 2 retries during SPI command</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/avrdude-verification-error-solution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming an ATMega With No Bootloader Using the USBtinyISP</title>
		<link>http://log.liminastudio.com/itp/physical-computing/programming-an-atmega-with-no-bootloader-using-the-usbtinyisp</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/programming-an-atmega-with-no-bootloader-using-the-usbtinyisp#comments</comments>
		<pubDate>Mon, 15 Aug 2011 03:38:09 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ATMega]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[avrdude]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=914</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/programming-an-atmega-with-no-bootloader-using-the-usbtinyisp' addthis:title='Programming an ATMega With No Bootloader Using the USBtinyISP '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The title says it all: for my &#8220;Deconspectrum&#8221; installation, I am burning a program onto a bunch of ATMega328 chips using a USBtinyISP (In-System Programmer).  At first I was running into a perplexing problem: the program was running much slower than it should have been.  I could tell immediately because I had a short POST [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/programming-an-atmega-with-no-bootloader-using-the-usbtinyisp' addthis:title='Programming an ATMega With No Bootloader Using the USBtinyISP '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The title says it all: for my <a href="http://log.liminastudio.com/projects/deconspectrum">&#8220;Deconspectrum&#8221; installation</a>, I am burning a program onto a bunch of ATMega328 chips using a USBtinyISP (In-System Programmer).  At first I was running into a perplexing problem: the program was running much slower than it should have been.  I could tell immediately because I had a short POST (Power-On Self Test) at the beginning of the program that flashes the LED Red-Green-Blue, and it was going far slower than it should have been.<span id="more-914"></span></p>
<p>My first thought was that there was a problem with the ATMega &#8220;fuses,&#8221; which are just settings for various esoteric details of the chip&#8217;s functioning, including clock rate.  But I had never had to bother with them before.  Then I made a further discovery that the only time the program ran correctly was if I installed the Arduino bootloader first and uploaded the program using it.  What gives?</p>
<p>Thanks to the plucky denizens of the ITP Physical Computing list, I learned that indeed, it was a matter of fuses—the Arduino IDE apparently only sets the correct fuses when burning the bootloader, not when burning a program directly using an ISP.</p>
<p>The solution: use avrdude, the program that Arduino uses to actually program the chip behind the scenes, directly.  This turned out to not only solve my problem, but to make the programming process much faster and simpler.  Avrdude takes a &#8220;hex&#8221; file as an input to transfer to the chip, which is the compiled bytecode that the ATMega actually runs.  This way, I only have to compile the program once, and burn it directly—and since I&#8217;m programming about 40 chips, this makes things far faster.</p>
<p>All you need to do is get the <a href="http://www.obdev.at/products/crosspack/index.html">AVR &#8220;CrossPack&#8221;</a> installed (for OSX; for Windows you can use AVR Studio or a number of other packages) and then find your hex file.  In the Arduino IDE, hold Shift while pressing the &#8220;Verify&#8221; button to produce a verbose debug output.  In there you&#8217;ll see a path like this:</p>
<pre>/var/folders/9t/7qf1680d2pqgd0hy6qbfkqsr0000gn/T/build5025172614724793636.tmp/myProgram.cpp.hex</pre>
<p>You can then copy that file to your project directory:</p>
<pre>cp /var/folders/.../myProgram.cpp.hex ~/Projects/myProject/myProgram.cpp.hex</pre>
<p>And program your chip like so:</p>
<pre>avrdude -c usbtiny -p m328p -b 57600 -U flash:w:myProgram.cpp.hex:i -U efuse:w:0x05:m -U hfuse:w:0xde:m -U lfuse:w:0xff:m</pre>
<p>Those settings are for the ATMega328; for the 168 use:</p>
<pre>-p m168</pre>
<p>To get a list of parts, type:</p>
<pre>avrdude -c avrisp</pre>
<p>And there you have it! You&#8217;ll find that this saves a lot of time if you have to program lots of chips. Besides, not using the Arduino bootloader will save a little space on your chip <img src='http://log.liminastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/programming-an-atmega-with-no-bootloader-using-the-usbtinyisp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino: Compensating for a Logarithmic Curve</title>
		<link>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve</link>
		<comments>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve#comments</comments>
		<pubDate>Thu, 04 Aug 2011 20:05:45 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Logarithm]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=904</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve' addthis:title='Arduino: Compensating for a Logarithmic Curve '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Did you know that the scale of acoustic pitches is logarithmic?  This means that, even though we perceive the scale of notes as increasing or decreasing linearly, the actual frequencies are doubling or halving with each octave. In my Deconspectrum installation, I&#8217;m mapping acoustic frequencies to color.  If I mapped them linearly, the colors would [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve' addthis:title='Arduino: Compensating for a Logarithmic Curve '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Did you know that the scale of acoustic pitches is logarithmic?  This means that, even though we perceive the scale of notes as increasing or decreasing linearly, the actual frequencies are doubling or halving with each octave.</p>
<p>In my <a href="http://log.liminastudio.com/projects/deconspectrum">Deconspectrum installation</a>, I&#8217;m mapping acoustic frequencies to color.  If I mapped them linearly, the colors would change very rapidly in the low frequencies, and then stop changing as obviously as the pitch gets higher.  This is not the effect you would expect, since you want each pitch to be represented by another color.</p>
<p>The solution is to map frequency to color (hue) logarithmically instead of linearly.  Thankfully, AVR C gives us a handy base-10 log function:</p>
<pre>int hueFreq = log10(frequency - FREQ_MIN) * hueScale;</pre>
<p>If we graph this, we get:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Lin.png"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-905" title="Freq_Hue_Lin" src="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Lin-300x165.png" alt="" width="300" height="165" /></a>The &#8216;y&#8217; scale is hue and the &#8216;x&#8217; is frequency.  You can see that, with each octave, the change in color progresses more naturally, mimicking our linear perception of pitch.</p>
<p>Here&#8217;s the same graph with a logarithmic frequency axis:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Log.png"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-906" title="Freq_Hue_Log" src="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Log-300x161.png" alt="" width="300" height="161" /></a>The dotted line is the log10 function without the cutoff, so you can see the &#8220;simulated&#8221; linearity.</p>
<p>Handy, and highly effective!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino: Controlling an RGB LED by Hue</title>
		<link>http://log.liminastudio.com/itp/physical-computing/arduino-controlling-an-rgb-led-by-hue</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/arduino-controlling-an-rgb-led-by-hue#comments</comments>
		<pubDate>Thu, 04 Aug 2011 19:54:08 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[RGB LED]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=902</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/arduino-controlling-an-rgb-led-by-hue' addthis:title='Arduino: Controlling an RGB LED by Hue '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Hooking up an RGB LED to an Arduino isn&#8217;t hard by itself, but controlling it can be—if you know what color you want to display, how do you know what R, G and B values that is? Here&#8217;s some Arduino code, adapted and simplified from Kasper Kamperman, that I am using in my Deconspectrum art [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/arduino-controlling-an-rgb-led-by-hue' addthis:title='Arduino: Controlling an RGB LED by Hue '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Hooking up an RGB LED to an Arduino isn&#8217;t hard by itself, but controlling it can be—if you know what color you want to display, how do you know what R, G and B values that is?</p>
<p>Here&#8217;s some Arduino code, adapted and simplified from <a href="http://www.kasperkamperman.com/blog/arduino/arduino-programming-hsb-to-rgb/">Kasper Kamperman</a>, that I am using in my <a href="http://log.liminastudio.com/projects/deconspectrum">Deconspectrum art installation</a> to do just that:<span id="more-902"></span></p>
<pre>void setLED(int hue, int l){
	int col[3] = {0,0,0};
	getRGB(hue, 255, l, col);
	ledWrite(col[0], col[1], col[2]);
}

void getRGB(int hue, int sat, int val, int colors[3]) {
	// hue: 0-259, sat: 0-255, val (lightness): 0-255
	int r, g, b, base;

	if (sat == 0) { // Achromatic color (gray).
		colors[0]=val;
		colors[1]=val;
		colors[2]=val;
	} else  {
		base = ((255 - sat) * val)&gt;&gt;8;
		switch(hue/60) {
			case 0:
				r = val;
				g = (((val-base)*hue)/60)+base;
				b = base;
				break;
			case 1:
				r = (((val-base)*(60-(hue%60)))/60)+base;
				g = val;
				b = base;
				break;
			case 2:
				r = base;
				g = val;
				b = (((val-base)*(hue%60))/60)+base;
				break;
			case 3:
				r = base;
				g = (((val-base)*(60-(hue%60)))/60)+base;
				b = val;
				break;
			case 4:
				r = (((val-base)*(hue%60))/60)+base;
				g = base;
				b = val;
				break;
			case 5:
				r = val;
				g = base;
				b = (((val-base)*(60-(hue%60)))/60)+base;
				break;
		}
		colors[0]=r;
		colors[1]=g;
		colors[2]=b;
	}
}

void ledWrite(int r, int g, int b){
	analogWrite(LED_RED, 255-r);
	analogWrite(LED_GREEN, 255-g);
	analogWrite(LED_BLUE, 255-b);
}</pre>
<p>This gives you a very straightforward setLED function that takes a Hue from 0-359 and a Lightness from 0-255 (it could easily be adapted to specify the Saturation as well, which I have fixed at the maximum).</p>
<p>Note that the ledWrite function is designed for common-anode LEDs, where the microprocessor is current-sinking instead of sourcing; if you are current-sourcing, just take out the 255-val inversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/arduino-controlling-an-rgb-led-by-hue/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Easy programming for breadboard Arduinos</title>
		<link>http://log.liminastudio.com/itp/physical-computing/easy-programming-for-breadboard-arduinos</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/easy-programming-for-breadboard-arduinos#comments</comments>
		<pubDate>Mon, 02 May 2011 17:55:57 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=838</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/easy-programming-for-breadboard-arduinos' addthis:title='Easy programming for breadboard Arduinos '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you&#8217;ve never made a breadboard Arduino, you really ought to try it (I have a quick tutorial)—you&#8217;ll suddenly discover that you rarely need an actual (and expensive) Arduino anymore.  The Arduino is built around the Atmel ATmega microprocessor, which you can buy from various places for roughly only $4-5! However, there are a few [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/easy-programming-for-breadboard-arduinos' addthis:title='Easy programming for breadboard Arduinos '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p><a href="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0728.jpg"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-850" title="Breadboard Arduino + Programming Board" src="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0728-300x224.jpg" alt="" width="300" height="224" /></a>If you&#8217;ve never made a breadboard Arduino, you really ought to try it (<a href="http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun">I have a quick tutorial</a>)—you&#8217;ll suddenly discover that you rarely need an actual (and expensive) Arduino anymore.  The Arduino is built around the Atmel ATmega microprocessor, which you can buy from various places for roughly only $4-5!</p>
<p>However, there are a few things about it that aren&#8217;t obvious at first, such as how to connect it to your computer via USB and make it programmable.<br />
<span id="more-838"></span> First off, be sure that your ATmega chip has the Arduino bootloader on it.  If you bought it from a major supplier such as Mouser or Digi-Key, it does not have the bootloader.  Sparkfun (among others) sells them with bootloaders.</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0720.jpg"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-855" title="Programming Header" src="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0720-300x224.jpg" alt="" width="300" height="224" /></a>Second, you&#8217;ll need an <a href="http://www.sparkfun.com/products/9873">FTDI USB breakout board</a>.  This connects to the TX and RX serial pins on the microprocessor and supplies a USB interface and firmware that your computer can recognize and use.  You&#8217;ll need the FTDI drivers for your system, which come with the Arduino software.</p>
<p>Third: the real work.  You need to connect some pins from the USB board to your breadboard:</p>
<ul>
<li>GND</li>
<li>TX</li>
<li>RX</li>
<li>DTR</li>
<li>Optional: 5V (if your breakout board supplies it)</li>
</ul>
<p>As you can see in the photo, I soldered up a handy little header so I can plug it right into a breadboard.  The serial pins are connected like so: TX→RX, RX→TX.  DTR is connected to a .1µF capacitor that goes to the RESET pin on the ATmega (pin 1).  That pin must also be connected to +5V via a 10kΩ resistor.</p>
<p>The DTR pin is the secret sauce: it pulls the reset pin down, which the Arduino bootloader requires to be programmed.  If you didn&#8217;t have this, you&#8217;d have to reset it by hand.  This way, it&#8217;s completely automatic, just like a regular Arduino board.</p>
<p>Let me know if this works for you!  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/easy-programming-for-breadboard-arduinos/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Breadboard Arduino: Fast, Cheap and Fun</title>
		<link>http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun</link>
		<comments>http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun#comments</comments>
		<pubDate>Mon, 02 May 2011 17:34:15 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=849</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun' addthis:title='Breadboard Arduino: Fast, Cheap and Fun '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you&#8217;ve been enjoying making stuff with the Arduino, but don&#8217;t want to buy more Arduino boards just to make a new project, fear not—you don&#8217;t need them! The Arduino board is just a convenient wrapper around the ATmega microprocessor, and it&#8217;s easy to recreate on a breadboard.  Here&#8217;s what you&#8217;ll need: ATmega328 (with Arduino [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun' addthis:title='Breadboard Arduino: Fast, Cheap and Fun '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you&#8217;ve been enjoying making stuff with the Arduino, but don&#8217;t want to buy more Arduino boards just to make a new project, fear not—you don&#8217;t need them!</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0731.jpg"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-851" title="Breadboard Arduino" src="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0731-224x300.jpg" alt="" width="224" height="300" /></a>The Arduino board is just a convenient wrapper around the ATmega microprocessor, and it&#8217;s easy to recreate on a breadboard.  Here&#8217;s what you&#8217;ll need:<br />
<span id="more-849"></span></p>
<ul>
<li><a href="http://www.sparkfun.com/products/10524">ATmega328</a> (with Arduino bootloader)</li>
<li><a href="http://www.sparkfun.com/products/107">5V regulator</a> (i.e. L7805)</li>
<li><a href="http://www.sparkfun.com/products/8375">.1µF capacitor</a> (the little yellowish disc kind that says &#8220;104&#8243; on it)</li>
<li><a href="http://www.sparkfun.com/products/9420">16mhz resonator</a></li>
<li>10kΩ resistor</li>
<li>&gt;5V power supply (can be any power supply you have, such as wall-warts, since we&#8217;re using our own regulator)</li>
<li>Optional: <a href="http://www.sparkfun.com/products/9716">FTDI USB breakout board</a> (for programming from a computer)</li>
</ul>
<p>The bootloader is what makes the microprocessor easy to program with the Arduino environment.  You can also buy ATmegas <a href="http://www.sparkfun.com/products/9061">without the bootloader</a> for about a dollar cheaper, but they must have the bootloader manually loaded on to use Arduino.</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0728.jpg"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-850" title="Breadboard Arduino + Programming Board" src="http://log.liminastudio.com/wp-content/uploads/2011/05/IMG_0728-300x224.jpg" alt="" width="300" height="224" /></a>The resonator is a handy package that combines a crystal, which is where the microprocessor gets its clock signal from, and two capacitors, so all you have to do is plug it into the ATmega.</p>
<p>If you have an ATmega that&#8217;s already loaded with your program, you can just build this board as-is without the capacitor and leave pin 1 (RESET) connected to +5V via the 10k &#8220;pull-up&#8221; resistor.  You can even program a chip on an Arduino, remove it and plug it into your breadboard setup.</p>
<p>The one part remaining that I haven&#8217;t mentioned is the programming header I made, on the top right of the top photo (fully visible in the second photo).  This connects to the FTDI USB board I describe in my <a href="http://log.liminastudio.com/uncategorized/easy-programming-for-breadboard-arduinos">easy breadboard Arduino programming tutorial</a>.  The pins are, from top to bottom: Ground (Black), RX (White), TX (Green), DTR (Yellow).</p>
<p>Lastly, though not pictured here, it is good practice to use decoupling capacitors on your power supply to protect your microcontroller from any irregularities, as described in <a href="http://www.sparkfun.com/tutorials/57">this tutorial</a> (a few pages down).</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/physical-computing/breadboard-arduino-fast-cheap-and-fun/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How to read a chain of TMP421 Temperature Sensors with an Arduino</title>
		<link>http://log.liminastudio.com/programming/how-to-read-a-chain-of-tmp421-temperature-sensors-with-an-arduino</link>
		<comments>http://log.liminastudio.com/programming/how-to-read-a-chain-of-tmp421-temperature-sensors-with-an-arduino#comments</comments>
		<pubDate>Thu, 07 Apr 2011 21:12:56 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=815</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/how-to-read-a-chain-of-tmp421-temperature-sensors-with-an-arduino' addthis:title='How to read a chain of TMP421 Temperature Sensors with an Arduino '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I recently made some minor modifications to the Liquidware Arduino Temperature Sensor Library which is designed to read from a single TMP421 sensor from Modern Device (the chip is made by TI).  You can download my modified library, LibTemperature2. Instantiate a LibTemperature2 object with the address of the sensor, which is determined by the A0 [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/how-to-read-a-chain-of-tmp421-temperature-sensors-with-an-arduino' addthis:title='How to read a chain of TMP421 Temperature Sensors with an Arduino '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I recently made some minor modifications to the Liquidware Arduino Temperature Sensor Library which is designed to read from a single TMP421 sensor from Modern Device (the chip is made by TI).  You can download my modified library, <a href="http://log.liminastudio.com/wp-content/uploads/2011/04/LibTemperature2.zip">LibTemperature2</a>.</p>
<p>Instantiate a LibTemperature2 object with the address of the sensor, which is determined by the A0 and A1 pins on the breakout board according to this chart:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/04/Screen-shot-2011-04-07-at-5.07.59-PM.png"  rel="lightbox[roadtrip]"><img class="size-full wp-image-817 alignnone" title="Screen shot 2011-04-07 at 5.07.59 PM" src="http://log.liminastudio.com/wp-content/uploads/2011/04/Screen-shot-2011-04-07-at-5.07.59-PM.png" alt="" width="394" height="259" /></a></p>
<p>&#8217;0&#8242; means Ground, &#8217;1&#8242; means Vcc, and &#8216;Float&#8217; means unconnected.  So to address 0x1C (0011100b), connect A0 to ground and leave A1 unconnected.  Note that the default address is 0x2A.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/how-to-read-a-chain-of-tmp421-temperature-sensors-with-an-arduino/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>byteSlice()</title>
		<link>http://log.liminastudio.com/itp/byteslice</link>
		<comments>http://log.liminastudio.com/itp/byteslice#comments</comments>
		<pubDate>Sat, 01 May 2010 03:17:33 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thesis]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=605</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/byteslice' addthis:title='byteSlice() '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Here&#8217;s a weird little function I just wrote to &#8220;slice&#8221; an integer out of a byte: int byteSlice(byte input, byte startIndex, byte endIndex){ // generates an integer value from an arbitrary slice of a byte // Example: // // index: 01234567 // input = B01101100 (int 108) // // startIndex = 1 // endIndex = [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/byteslice' addthis:title='byteSlice() '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Here&#8217;s a weird little function I just wrote to &#8220;slice&#8221; an integer out of a byte:</p>
<pre>int byteSlice(byte input, byte startIndex, byte endIndex){

  // generates an integer value from an arbitrary slice of a byte
  // Example:
  //
  // index:   01234567
  // input = B01101100 (int 108)
  //
  // startIndex = 1
  // endIndex = 4
  // slice = B1101
  // returns int 13

  byte output;

  // shift left to shave off bits before startIndex
  output = input << startIndex;
  // shift right to shave off bits after endIndex
  output = output >> (7-endIndex) + startIndex;

  return int(output);
}</pre>
<p>This basically takes out a chunk of a byte and gives you the integer representation of its bits.  The input index byte datatypes are a neurotic memory optimization, since the indices can&#8217;t be greater than 7. <img src='http://log.liminastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Example Arduino implementation:</p>
<pre>void setup(){

  Serial.begin(9600);
  byte in = 108;

  Serial.print(in, DEC);
  Serial.print("\t");
  Serial.println(in, BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 0, 7), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 0, 7), BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 1, 4), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 1, 4), BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 3, 6), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 3, 6), BIN);
}

void loop(){
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/byteslice/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

