<?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>bildr</title>
	<atom:link href="http://bildr.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://bildr.org</link>
	<description>bildr - communal know-how</description>
	<lastBuildDate>Thu, 31 Jan 2013 22:41:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Sensing Humidity With The SHT15 + Arduino</title>
		<link>http://bildr.org/2012/11/sht15-arduino/</link>
		<comments>http://bildr.org/2012/11/sht15-arduino/#comments</comments>
		<pubDate>Tue, 27 Nov 2012 05:35:00 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Humidity]]></category>
		<category><![CDATA[SHT15]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=1914</guid>
		<description><![CDATA[
The SHT15 is a digital humidity sensor that outputs a fully calibrated humidity reading. And&#8230; because what we are measuring is actually relative humidity, and relative humidity being relative to temperature, the SHT15 has a builtin digital thermometer. This makes things much easier to work with than sensors without a thermometer onboard. You can pick [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/01/SHT15.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
The SHT15 is a digital humidity sensor that outputs a fully calibrated humidity reading. And&#8230; because what we are measuring is actually <a href="http://en.wikipedia.org/wiki/Relative_humidity">relative humidity</a>, and relative humidity being relative to temperature, the SHT15 has a builtin digital thermometer. This makes things much easier to work with <a href="http://bildr.org/2012/11/hih4030-arduino/">than sensors without a thermometer onboard</a>. You can <a href="https://www.sparkfun.com/products/8257">pick one up from sparkFun here</a>.</p>
<h3>Hooking it up</h3>
<p>The SHT15 uses a two-wire connection for communication that is similar to, but not, I2C. So we wont be able to use the Arduino&#8217;s dedicated lines for this. The down side is it is a bit slower to get readings from, the plus side is that you can connect it to any 2 digital pins you want. We are using pins 2 and 3 on our arduino.</p>
<p><b style="color: #D00;">BEFORE YOU SOLDER IT UP&#8230; </b>Note that this board can not be washed! So if you are using flux, or solder that you normally clean up, don&#8217;t (They actually recommend to use &#8220;no-clean&#8221; solder just so you don&#8217;t have to worry about it). And be extremely careful not to get it wet at all. </p>
<p><b style="color: #D00;">AFTER YOU SOLDER IT UP&#8230; </b> To get a clean reading, the sensor needs to be stored at >75% humidity for at least 12 hours to allow the polymer to re-hydrate (just what the doc says). If you don&#8217;t, your SHT15 may read an offset that slowly disappears if exposed to ambient conditions. Alternatively the re-hydration process may be performed at ambient conditions (>40% Humidity) for 5 + days.</p>
<p>Im not exactly sure how you do that&#8230; But someone noted that they put it in a ziplock with a wet towel (not touching) for 12H.</p>
<h3>Code</h3>
<p>The code for this is a bit wacky (as with most digital sensors), but it is split up pretty nicely, and is as easy to read as it can be.</p>
<p><b>Note that the readings are a bit slow to return a value (100+ ms).</b></p>
</div>
<div class="rightColumn">
<a href="http://bildr.org/blog/wp-content/uploads/2012/11/sht15-arduino-hookup.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/sht15-arduino-hookup-400x678.png" alt="" title="sht15-arduino-hookup" width="400" height="678" class="alignleft size-medium wp-image-2361" /></a></p>
</div>
</div>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="co1">//Based of the wiring code at http://wiring.org.co/learning/basics/humiditytemperaturesht15.html</span>

<span class="kw4">int</span> SHT_clockPin <span class="sy0">=</span> <span class="nu0">3</span><span class="sy0">;</span>  <span class="co1">// pin used for clock</span>
<span class="kw4">int</span> SHT_dataPin  <span class="sy0">=</span> <span class="nu0">2</span><span class="sy0">;</span>  <span class="co1">// pin used for data</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// open serial at 9600 bps</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">//these can take a bit to get the values (100ms or so)</span>
  <span class="kw4">float</span> temperature <span class="sy0">=</span> getTemperature<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">float</span> humidity <span class="sy0">=</span> getHumidity<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">Serial</span>.<span class="me1">print</span><span class="br0">&#40;</span>temperature<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">Serial</span>.<span class="me1">print</span><span class="br0">&#40;</span><span class="st0">&quot; | &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>humidity<span class="br0">&#41;</span><span class="sy0">;</span>

<span class="br0">&#125;</span>






<span class="kw4">float</span> getTemperature<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">//Return Temperature in Celsius</span>
  SHT_sendCommand<span class="br0">&#40;</span>B00000011<span class="sy0">,</span> SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  SHT_waitForResult<span class="br0">&#40;</span>SHT_dataPin<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw4">int</span> val <span class="sy0">=</span> SHT_getData<span class="br0">&#40;</span>SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  SHT_skipCrc<span class="br0">&#40;</span>SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">float</span><span class="br0">&#41;</span>val <span class="sy0">*</span> 0.01 <span class="sy0">-</span> <span class="nu0">40</span><span class="sy0">;</span> <span class="co1">//convert to celsius</span>
<span class="br0">&#125;</span>

<span class="kw4">float</span> getHumidity<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">//Return  Relative Humidity</span>
  SHT_sendCommand<span class="br0">&#40;</span>B00000101<span class="sy0">,</span> SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  SHT_waitForResult<span class="br0">&#40;</span>SHT_dataPin<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">int</span> val <span class="sy0">=</span> SHT_getData<span class="br0">&#40;</span>SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  SHT_skipCrc<span class="br0">&#40;</span>SHT_dataPin<span class="sy0">,</span> SHT_clockPin<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">return</span> <span class="sy0">-</span>4.0 <span class="sy0">+</span> 0.0405 <span class="sy0">*</span> val <span class="sy0">+</span> <span class="sy0">-</span>0.0000028 <span class="sy0">*</span> val <span class="sy0">*</span> val<span class="sy0">;</span> 
<span class="br0">&#125;</span>


<span class="kw4">void</span> SHT_sendCommand<span class="br0">&#40;</span><span class="kw4">int</span> command<span class="sy0">,</span> <span class="kw4">int</span> dataPin<span class="sy0">,</span> <span class="kw4">int</span> clockPin<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// send a command to the SHTx sensor</span>
  <span class="co1">// transmission start</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="co1">// shift out the command (the 3 MSB are address and must be 000, the last 5 bits are the command)</span>
  <span class="kw3">shiftOut</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> clockPin<span class="sy0">,</span> MSBFIRST<span class="sy0">,</span> command<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="co1">// verify we get the right ACK</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">INPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">digitalRead</span><span class="br0">&#40;</span>dataPin<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;ACK error 0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">digitalRead</span><span class="br0">&#40;</span>dataPin<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;ACK error 1&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>


<span class="kw4">void</span> SHT_waitForResult<span class="br0">&#40;</span><span class="kw4">int</span> dataPin<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// wait for the SHTx answer</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">INPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw4">int</span> ack<span class="sy0">;</span> <span class="co1">//acknowledgement</span>

  <span class="co1">//need to wait up to 2 seconds for the value</span>
  <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">1000</span><span class="sy0">;</span> <span class="sy0">++</span>i<span class="br0">&#41;</span><span class="br0">&#123;</span>
    <span class="kw3">delay</span><span class="br0">&#40;</span>2<span class="br0">&#41;</span><span class="sy0">;</span>
    ack <span class="sy0">=</span> <span class="kw3">digitalRead</span><span class="br0">&#40;</span>dataPin<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span>ack <span class="sy0">==</span> <span class="kw2">LOW</span><span class="br0">&#41;</span> <span class="kw2">break</span><span class="sy0">;</span>
  <span class="br0">&#125;</span>

  <span class="kw1">if</span> <span class="br0">&#40;</span>ack <span class="sy0">==</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span> <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;ACK error 2&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">int</span> SHT_getData<span class="br0">&#40;</span><span class="kw4">int</span> dataPin<span class="sy0">,</span> <span class="kw4">int</span> clockPin<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// get data from the SHTx sensor</span>

  <span class="co1">// get the MSB (most significant bits)</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">INPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">byte</span> MSB <span class="sy0">=</span> shiftIn<span class="br0">&#40;</span>dataPin<span class="sy0">,</span> clockPin<span class="sy0">,</span> MSBFIRST<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="co1">// send the required ACK</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="co1">// get the LSB (less significant bits)</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">INPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">byte</span> LSB <span class="sy0">=</span> shiftIn<span class="br0">&#40;</span>dataPin<span class="sy0">,</span> clockPin<span class="sy0">,</span> MSBFIRST<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">return</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>MSB <span class="sy0">&lt;&lt;</span> 8<span class="br0">&#41;</span> <span class="sy0">|</span> LSB<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//combine bits</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> SHT_skipCrc<span class="br0">&#40;</span><span class="kw4">int</span> dataPin<span class="sy0">,</span> <span class="kw4">int</span> clockPin<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// skip CRC data from the SHTx sensor</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">pinMode</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">OUTPUT</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>dataPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>clockPin<span class="sy0">,</span> <span class="kw2">LOW</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/sht15-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Big Easy Stepper Motor Driver + Arduino</title>
		<link>http://bildr.org/2012/11/big-easy-driver-arduino/</link>
		<comments>http://bildr.org/2012/11/big-easy-driver-arduino/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 13:42:08 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[motor]]></category>
		<category><![CDATA[Step Motor]]></category>
		<category><![CDATA[Stepper]]></category>
		<category><![CDATA[Stepper Motor]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2157</guid>
		<description><![CDATA[
Stepper (or step) motors are really cool. They are perfect for automation or any time you need a motor to turn to a specific point, at a specific speed, in a specific direction. And, unlike typical motors, steppers are able to do all of this, and hold their position when they are not moving &#8211; [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/11/bigEasyDriver-Arduino.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
<p><a href="http://wiki.bildr.org/index.php/Step Motor">Stepper</a> (or step) motors are really cool. They are perfect for automation or any time you need a motor to turn to a specific point, at a specific speed, in a specific direction. And, unlike typical motors, steppers are able to do all of this, and hold their position when they are not moving &#8211; The trade off is that they cant move as fast, and you have to power them at full power all the time, but you get total control in return.</p>
<p>Steppers have a minimum amount they can move known as a step. You can feel these steps if you slowly turn your stepper by hand. The most common steppers have 200 steps per revolution, so all movement is in 1.8º increments (360º / 200). Controlling them can get tricky at first, so today we are doing an article on using the <a href="http://www.sparkfun.com/products/10735">Big EasyDriver Stepper Motor Driver</a>. The big easyDriver is the big brother of the <a href="http://bildr.org/2011/06/easydriver/">easy driver we wrote about last year</a>. It is able to take a lot more abuse and power, so it isn&#8217;t as easy to destroy as the easy driver, can power much larger motors, and it also gives you a little more control by letting you change the microstepping setting.</p>
<h3>Motor Voltage / Current</h3>
<p>A lot of people ask what voltage they should use to power their motor. Well, when using a stepper driver, you are powering the driver, not the motor. The driver will take over powering the motor for you.</p>
<p>It is best to power the driver with the highest voltage you can <b>( up to 35V max for this driver )</b>. This will allow the motor to spin faster than if powered at a lower voltage. Exactly why this is is pretty complex, but if you want to know more about it, you should really read this: <a href="http://www.geckodrive.com/support/step-motor-basics.html">Gecko Drive &#8211; Step Motor Basics</a></p>
<p>On the bigEasy driver is a mini potentiometer to control the current to the motor. This varies between 0ma and 2A (2000ma). You want to set it to whatever your motor is rated to. Too high, and you could burn the motor up, too low, you wont get all the power out of your motor. <b style="color: red">Note: The arrow indicators on the current adjustment potentiometer are backwards. Keep this in mind when adjusting the current limits.</b> If you are running a higher power motor, you will probably want to put a heat sink on the driver as well. (I have heard anything over 1A will need it.)</p>
</div>
<div class="rightColumn">
<a href="http://bildr.org/blog/wp-content/uploads/2012/11/big-easy-driver-arduino-2.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/big-easy-driver-arduino-2-400x656.png" alt="" title="big-easy-driver-arduino-2" width="400" height="656" class="alignleft size-medium wp-image-2273" /></a></p>
</div>
</div>
<div class="wideBody">
<h3>Hooking it up</h3>
<p>Even though there are some 30 pins on the Big Easy Driver, we only need a few to get this up and running. In fact, a good deal of the pins are actually just duplicates that are spaced out differently.</p>
<h4 style="color: #3399cc" >The barebones setup:</h4>
<p><b>Power the driver with 8-35v</b> &#8211; If using a wall adapter, make sure the adapter has at least enough current for the motor. A higher current/amperage rating is better, and just means it wont burn out. (The Big Easy Driver can supply up to 2 amps)<br />
<b>Connect the 3 control wires</b> from the &#8220;gnd&#8221;, &#8220;dir&#8221;, and &#8220;step&#8221; of the Big Easy Driver to the Arduino as shown.<br />
<b>Connect the stepper motor to the driver</b> &#8211; For me the red/green were one pair, and the blue/yellow was another. If this does not work for you, see the section below on <a href="#mototPairs">finding your motors coil pairs</a>.</p>
<h3>Code</h3>
<p>For the arduino code for the driver, im going to be using <a href="http://www.open.com.au/mikem/arduino/AccelStepper/">AccelStepper Library</a>. This is an amazing library that I use for all my stepper needs now. It is even does acceleration and deceleration, supports multiple drivers at once, and most importantly it is non blocking. Meaning, you can be moving your motor as you are reading from a sensor, or turning on lights etc.</p>
<p>The library even keeps track of the position of the motor. So if you tell it to go to 10,000 &#8211; It knows it is at 9,00 already, so it moves an additional 1000 steps. Then you can tell it to go home, and it will go back 10,000 steps to 0.</p>
<p>I have included 2 examples in the code. One for a single motor setup, and another for a dual motor setup so you can see how that would work.</p>
<p><b>I highly recommend you download the full library from the author. The version I have here is barebones with none of the examples. It is just here because I believe if you post code, you should post everything you need to make it work</b>
</div>
<div class="columnBody">
<div class="leftColumn">
<p>To make this code work, <strong>before you load the code, or even open the Arduino program</strong>, we need to place the &#8220;AccelStepper&#8221; folder into your Arduino Library. If you don’t know where that is by default, Look to the right.<br />
If you click the download button to the right of “Arduino” you can download the whole thing as a zip, so you dont need to copy all the files.</p>
</div>
<div class="rightColumn">
<h3>Default Library Folder Location</h3>
<p><span style="font-size: 10px; line-height:12px;"><strong>On your Mac:</strong>: In (home directory)/Documents/Arduino/libraries<br />
<strong>On your PC:</strong>: My Documents -> Arduino -> libraries<br />
<strong>On your Linux box:</strong>: (home directory)/sketchbook/libraries<br />
</span></p>
</div>
</div>

	<div class="clear">
	<script src="http://code.bildr.org/render/AccelStepper/arduino.js"></script>
	</div>
	
<div class="wideBody">
<p><H2>Additional Information</h2>
<p></p>
<h3 id="mototPairs">Finding Your Motors Coil Pairs</h3>
<p>This driver only needs 4 wires from your stepper. If you have a 4 wire stepper, awesome! If you have a 6 wire stepper, it will be slightly trickier. But no matter what, we need to find the 2 main coils inside of the motor. <b>And if you get it wrong, the motor will just twitch or not move, but you wont break it.</b></p>
<h4 style="color: #3399cc" >4 wire motor</h4>
<p>Using an ohmMeter, pick one wire at random, and test it with the others until you find a pair that shows resistance of a few ohms (1 &#8211; 200ohms most often). Those 2 are your &#8220;pair A&#8221;. Make sure the other 2 wires have the same resistance on them, (if not, it may be broken) and that is your &#8220;pair B&#8221;. With the two pairs of wires, there isnt a backwards, so just plug wires from &#8220;pair A&#8221; into the &#8220;A&#8221; on the driver, and &#8220;pair B&#8221; into &#8220;B&#8221;.</p>
<h4 style="color: #3399cc" >6 wire motor</h4>
<p>Checking the documents on the motor is the easiest, but if you dont have it, read on.</p>
<p>6 wire motors have two coils in them just like 4 wire motors. But 6 wire motors also have extra wires that connects to the middle of each coil (centers). So each coil actually has 3 wires, a center and two ends. We don&#8217;t use coil center wires, we just need the 4 coil ends (2 from each coil).</p>
<p>Basically, We need to find ends of the two coils. The ends of the coils will have twice the resistance as the center to an end. So we need two pairs of wire that have the highest resistance in the group.</p>
<p>The easiest way to find out the right 4 wires is to look at the documentation for the motor, but if you dont have that, you can with some testing, find the right ones.</p>
<p>To find the correct 2 wires, we need to locate the 3 wires from each coil. Start by just picking one at random, and using an ohmMeter, test the resistance with the others until you find the 2 connected to that wire. (3 of them will show no connection because they are part of the other coil). Now, these 3 are for coil &#8220;A&#8221;. Now, take these 3 wires and test the resistance between any 2 of them until find the 2 that have the highest resistance. These are the two ends of that coil &#8220;A&#8221;. Do the same for the other 3 wires to locate the ends of coil &#8220;B&#8221;.</p>
<p>With the two pairs of wires, there isnt a backwards. So just plug wires from coil A into the A on the driver, and the two from coil B into b.</p>
<h4 style="color: #3399cc" >8 wire motor</h4>
<p>There is no way to do this without looking at the documentation.</p>
<h3>Microstepping</h3>
<p>Most stepper drivers offer something called microstepping, and the Big Easy Driver is no exception. As I mentioned before, steppers have that minimum movement called a step. Microstepping breaks down that step into smaller micro steps. Microstepping allows for smoother, quieter, more accurate control, at slower speeds.</p>
<p>When using microstepping, a step motor will require more &#8220;step pluses&#8221; to move the motor. For instance if you are using 16 microsteps (the default on the Big Easy Driver) per step, a 200 step motor would require 3200 &#8220;step pluses&#8221; to make a full revolution. Just take note when you wonder why telling it to step 200 steps barely rotates the motor.</p>
<p>Microstepping will reduce the maximum speed / torque of the motor (about 30% less), so it is a trade of speed vs smooth. Because of this, many high end drivers switch to full stepping (no microstepping) at higher speeds, and technically, you could do that with the big easyDriver, but it&#8217;s too complex for me to figure out, so I wont be covering that.
</p></div>
<div class="columnBody">
<div class="leftColumn">
<h4>Adjusting the microstepping</h4>
<p>The Big Easy Driver defaults to 16 step microstepping mode. If you want to reduce that, you can do so by pulling the MS1, MS2, and MS3 pins HIGH (connecting them to 5V) or LOW (connecting them to GND). Check out the chart on the side to see how  make the adjustments.</p>
</div>
<div class="rightColumn">
<a href="http://bildr.org/blog/wp-content/uploads/2012/11/microsteps.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/microsteps.png" alt="" title="microsteps" width="400" height="167" class="alignleft size-full wp-image-2275" /></a>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/big-easy-driver-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Touch Sliders With A Softpot + Arduino</title>
		<link>http://bildr.org/2012/11/touch-sliders-with-a-softpot-arduino/</link>
		<comments>http://bildr.org/2012/11/touch-sliders-with-a-softpot-arduino/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 13:33:59 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[softpot]]></category>
		<category><![CDATA[Touch]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2256</guid>
		<description><![CDATA[
You all know the potentiometer, you turn it, and you can read on your arduino where it was turned to. Well 3M makes a product called the softpot that is a linear touch potentiometer. So instead of turning a knob, you touch it. The really nice thing about these is that they are great for [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/11/softPot-arduino.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
You all know the potentiometer, you turn it, and you can read on your arduino where it was turned to. Well 3M makes a product called the softpot that is a linear touch potentiometer. So instead of turning a knob, you touch it.</p>
<p>The really nice thing about these is that they are great for prototypes because you can tell where someone touched it. So if you place a piece of paper with some printed buttons over it, you can mock up surface touch buttons. Or if you need to prototype a rotary touch wheel like the old ipods, but don&#8217;t want to get involved with complex capitative sensors, you can do that too.</p>
<p>There are a million uses for these, and they <a href="https://www.sparkfun.com/search/results?term=softpot&#038;what=products">come in a few sizes, shapes, and even offer high temperature versions</a>.</p>
<h3>Hooking it up</h3>
<p>The softpot sensors change their resistance depending on where they are touched. And because they work just like potentiometers you don&#8217;t need any extra parts to use them with your arduino. We can just plug in the middle pin to an analog in pin on the arduino and we are ready to go.</p>
<p>The arduino analogRead will vary between 0 and 1023 depending on where you touch it, (1023 when not being touched) and is linear, so it will be about 512 if touched in the middle.</p>
<h3 style="color: red">WARNING!!!!!</h3>
<p><b style="color: #900">If you touch the softpot at the top and the bottom at the same time, it will get really hot, really quick, and if you leave it for more than a second, you may burn it up. I have no clue why. But beware!</b></p>
<p><b style="color: #900">This is especially an issue on the round version. If you press down dead center on the bottom (where the straight parts come off of), you will be pressing on both sides of the pot and it will again get super hot and melt. SO DONT PRESS IT IN THE MIDDLE BOTTOM</b></p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/softpot-Straight-arduino.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/softpot-Straight-arduino-400x300.png" alt="" title="softpot-Straight-arduino" width="400" height="300" class="alignleft size-medium wp-image-2258" /></a></p>
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/softpot-round-arduino.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/softpot-round-arduino-400x455.png" alt="" title="softpot-round-arduino" width="400" height="455" class="alignleft size-medium wp-image-2257" /></a></p>
</div>
</div>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="kw4">int</span> softpotPin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">digitalWrite</span><span class="br0">&#40;</span>softpotPin<span class="sy0">,</span> <span class="kw2">HIGH</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//enable pullup resistor</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> softpotReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>softpotPin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>softpotReading<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/touch-sliders-with-a-softpot-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sensing Humidity With The HIH-4030 + Arduino</title>
		<link>http://bildr.org/2012/11/hih4030-arduino/</link>
		<comments>http://bildr.org/2012/11/hih4030-arduino/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 03:41:59 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Humidity]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2323</guid>
		<description><![CDATA[
Humidity is weird. Even though we experience it all the time, it&#8217;s not something we can normally guess with any accuracy. This is probably because when we talk about humidity, we are talking about relative humidity. Relative humidity is relative to temperature, so a change in temperature alone is enough to change the relative humidity. [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/11/HIH-4030-arduino.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
Humidity is weird. Even though we experience it all the time, it&#8217;s not something we can normally guess with any accuracy. This is probably because when we talk about humidity, we are talking about relative humidity. Relative humidity is relative to temperature, so a change in temperature alone is enough to change the relative humidity. This makes guessing the humidity extremely hard.</p>
<p>Well luckily measuring relative humidity is pretty simple with the HIH-4030. The HIH-4030 is a low-power, analog output sensor.</p>
<h3>Hooking It Up</h3>
<p>Hooking up the HIH-4030 to your arduino is super simple, just power it with 5V / Ground, and connect the out to an analog pin on the arduino. You may be able to run it with 3.3v, I haven&#8217;t tried it. But if you do, you need to change the &#8220;supplyVolt&#8221; value in the code from 5.0 to 3.3.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/HIH-4030_arduino_hookup1.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/HIH-4030_arduino_hookup1-400x275.png" alt="" title="HIH-4030_arduino_hookup" width="400" height="275" class="alignleft size-medium wp-image-2335" /></a></p>
</div>
</div>
<h3>Code</h3>
<p><strong style="color: #a00">Note that because determining relative humidity requires knowing an accurate temperature, you are going to want to use this in conjunction with a thermometer.</strong> To simplify things for you, the code just has a hard coded temperature that we pass to a function to get the humidity. You will want to replace that value with the value from your thermometer.</p>
<p>Also note that the sensor is sensitive to light, so for best performance, shield it from bright light.</p>
<p>Suggested Thermometers (with article):<br />
<a href="http://bildr.org/2011/01/tmp102-arduino/">TMP102</a><br />
<a href="http://bildr.org/2011/07/ds18b20-arduino/">DS18B20</a></p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="co1">//From the bildr article http://bildr.org/2012/11/hih4030-arduino/</span>

<span class="kw4">int</span> HIH4030_Pin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

  <span class="co1">//To properly caculate relative humidity, we need the temperature.</span>
  <span class="kw4">float</span> temperature <span class="sy0">=</span> <span class="nu0">25</span><span class="sy0">;</span> <span class="co1">//replace with a thermometer reading if you have it</span>
  <span class="kw4">float</span> relativeHumidity  <span class="sy0">=</span> getHumidity<span class="br0">&#40;</span>temperature<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>relativeHumidity<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">delay</span><span class="br0">&#40;</span>100<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow it down so you can read it</span>
<span class="br0">&#125;</span>


<span class="kw4">float</span> getHumidity<span class="br0">&#40;</span><span class="kw4">float</span> degreesCelsius<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">//caculate relative humidity</span>
  <span class="kw4">float</span> supplyVolt <span class="sy0">=</span> <span class="nu16">5.0</span><span class="sy0">;</span>

  <span class="co1">// read the value from the sensor:</span>
  <span class="kw4">int</span> HIH4030_Value <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>HIH4030_Pin<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">float</span> voltage <span class="sy0">=</span> HIH4030_Value<span class="sy0">/</span>1023. <span class="sy0">*</span> supplyVolt<span class="sy0">;</span> <span class="co1">// convert to voltage value</span>

  <span class="co1">// convert the voltage to a relative humidity</span>
  <span class="co1">// - the equation is derived from the HIH-4030/31 datasheet</span>
  <span class="co1">// - it is not calibrated to your individual sensor</span>
  <span class="co1">//  Table 2 of the sheet shows the may deviate from this line</span>
  <span class="kw4">float</span> sensorRH <span class="sy0">=</span> 161.0 <span class="sy0">*</span> voltage <span class="sy0">/</span> supplyVolt <span class="sy0">-</span> <span class="nu16">25.8</span><span class="sy0">;</span>
  <span class="kw4">float</span> trueRH <span class="sy0">=</span> sensorRH <span class="sy0">/</span> <span class="br0">&#40;</span>1.0546 <span class="sy0">-</span> 0.0026 <span class="sy0">*</span> degreesCelsius<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//temperature adjustment </span>

  <span class="kw1">return</span> trueRH<span class="sy0">;</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/hih4030-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sensing Weight With A Flexiforce + Arduino</title>
		<link>http://bildr.org/2012/11/flexiforce-arduino/</link>
		<comments>http://bildr.org/2012/11/flexiforce-arduino/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 03:41:48 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[flexiforce]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[weight]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2221</guid>
		<description><![CDATA[
Felxiforce is a force sensor that is very similar to FSRs we just wrote about in principal. They change their resistance when you apply force to them. (The flexi part of the name is because they are flexible) Felxiforces are about twice as expensive as their FSR cousins, but these are much more stable, and [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/11/flexi-force-arduino.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
Felxiforce is a force sensor that is very similar to <a href="http://bildr.org/2012/11/flexiforce-arduino/">FSRs we just wrote about</a> in principal. They change their resistance when you apply force to them. (The flexi part of the name is because they are flexible) Felxiforces are about twice as expensive as their FSR cousins, but these are much more stable, and are calibrated to a specific weight. <a href="https://www.sparkfun.com/search/results?term=flexiforce&#038;what=products">You can buy them in 1, 25, or 100lb</a> ratings. This article was written using the 100lb version.</p>
<p>Like the FSR I&#8217;m not sure if you can get a really precise weight reading from it, it seems a bit shaky, and the output seems to be logarithmic, not linear. But it does have a much larger range than the FSR, and in general will be better if you you need to sense a range of weights, or need to guess how much water is in a cup based on the weight.</p>
<p>When using the flexiforce, you need to make sure all the weight you want to sense is directed onto the small sensing area. So you may need to make a jig to direct the weight if you want to sense something you put on top of it.
</p></div>
<div class="rightColumn">
<a href="http://bildr.org/blog/wp-content/uploads/2012/11/flexiForce-arduino.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/flexiForce-arduino-400x300.png" alt="" title="flexiForce-arduino" width="400" height="300" class="alignleft size-medium wp-image-2222" /></a></p>
</div>
</div>
<h3>Hooking it up, and why</h3>
<p>The flexiforce sensor ranges its resistance between near infinite when not being touched, to under 25K ohms when you approach its weight limit. When barely touching it, it has a resistance of around 10M ohms.</p>
<p>We can measure that change using one of the Arduino&#8217;s analog inputs. But to do that, we need a fixed resistor (not changing) that we can use for that comparison (We are using a 10M (1,000,000 ohm) resistor). This is called a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a> and divides the 5v between the flexiforce and the resistor. </p>
<p>The analog read on your arduino is basically a voltage meter. At 5V (its max) it will read 1023, and at 0v it will read 0. So we can measure how much voltage is on the flexiforce using the analogRead and we will have our force reading.</p>
<p>The amount of that 5V that each part gets is proportional to its resistance. So if the the flexiforce and the resistor have the same resistance, the 5V is split evenly (2.5V) to each part. (analog reading of 512)</p>
<p>But if the flexiforce is pressed on pretty hard, reading only 25K of resistance, the 1M resistor is going to soak up 40 times as much of that 5V. So the FSR would only get .12V. (analog reading of 25)</p>
<p>And if something is barely pressing on it, the flexiforce may be 5M of resistance, so the flexiforce will soak up 5 times as much of that 5V as the 1M resistor. So the flexiforce would get 4.2V. (analog reading of 852)</p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="co1">//From the bildr article http://bildr.org/2012/11/flexiforce-arduino/</span>

<span class="kw4">int</span> flexiForcePin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> flexiForceReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>flexiForcePin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>flexiForceReading<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/flexiforce-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force Sensitive Resistor + Arduino</title>
		<link>http://bildr.org/2012/11/force-sensitive-resistor-arduino/</link>
		<comments>http://bildr.org/2012/11/force-sensitive-resistor-arduino/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 03:41:26 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[FSR]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2064</guid>
		<description><![CDATA[
The Force Sensitive Resistor, or FSR is one of those parts that fills bins in interaction design labs across the world. It&#8217;s a simple guy, a finicky guy, but it has its place in the maker toolbox. A FSR is just what it sounds like &#8211; a resistor that changes its resistance with force. So [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/03/FSR2.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
<p>The Force Sensitive Resistor, or FSR is one of those parts that fills bins in interaction design labs across the world. It&#8217;s a simple guy, a finicky guy, but it has its place in the maker toolbox.</p>
<p>A FSR is just what it sounds like &#8211; a resistor that changes its resistance with force. So if you press, sit, or punch it, its resistance changes. The finicky part tends to be when people want it to measure force with any sort of precision. It&#8217;s really not good for that, so if you need something sense even approximate weight or quantitative force, this is not your guy. But if you need something that will let you know if someone is sitting in a chair, or hugging a stuffed animal, this is it!</p>
<p>FSRs come in a wide variety of sizes, the larges ones can get a bit expensive, but you can probably <a href="https://www.sparkfun.com/search/results?term=fsr&#038;what=products">find one to fit your project</a>.</p>
<h3>Hooking it up, and why</h3>
<p>The FSR changes its resistance with force. It ranges from near infinite when not being touched, to under 300ohms when pressed really hard. So we can measure that change using one of the Arduino&#8217;s analog inputs. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 10K resistor). This is called a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a> and divides the 5v between the FSR and the resistor. </p>
<p>The analog read on your arduino is basically a voltage meter. At 5V (its max) it will read 1023, and at 0v it will read 0. So we can measure how much voltage is on the FSR using the analogRead and we will have our force reading.</p>
</div>
<div class="rightColumn">
<a href="http://bildr.org/blog/wp-content/uploads/2012/03/FSR_Arduino_Hookup1.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/03/FSR_Arduino_Hookup1-400x287.png" alt="" title="FSR_Arduino_Hookup" width="400" height="287" class="alignleft size-medium wp-image-2068" /></a></p>
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/03/Large_FSR_Arduino_Hookup.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/03/Large_FSR_Arduino_Hookup-400x241.png" alt="" title="Large_FSR_Arduino_Hookup" width="400" height="241" class="alignleft size-medium wp-image-2070" /></a></p>
</div>
</div>
<p>The amount of that 5V that each part gets is proportional to its resistance. So if the the FSR and the resistor have the same resistance, the 5V is split evenly (2.5V) to each part. (analog reading of 512)</p>
<p>But if the FSR is pressed on pretty hard, reading only 1K of resistance, the 10K resistor is going to soak up 10 times as much of that 5V. So the FSR would only get .45V. (analog reading of 92)</p>
<p>And if something is barely pressing on it, the FSR may be 40K of resistance, so the FSR will soak up 4 times as much of that 5V as the 10K resistor. So the FSR would get 4V. (analog reading of 819)</p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="co1">//From the article: http://bildr.org/2012/11/force-sensitive-resistor-arduino</span>

<span class="kw4">int</span> FSR_Pin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> FSRReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>FSR_Pin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>FSRReading<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/force-sensitive-resistor-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proximity Sensing with the VCNL4000 + Arduino</title>
		<link>http://bildr.org/2012/11/vcnl4000-arduino/</link>
		<comments>http://bildr.org/2012/11/vcnl4000-arduino/#comments</comments>
		<pubDate>Fri, 23 Nov 2012 15:05:41 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Proximity]]></category>
		<category><![CDATA[VCNL4000]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=1901</guid>
		<description><![CDATA[
I&#8217;m not really sure why, but proximity sensors are some of my favorite things in the sensor world. Maybe because there are so many of them? Who knows. Whatever the reason, the VCNL4000 is another proximity sensor that caught my eye, so I picked one up from Sparkfun on this handy breakout board. The VCNL4000 [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/01/VCNL4000.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
I&#8217;m not really sure why, but proximity sensors are some of my favorite things in the sensor world. Maybe because there are so many of them? Who knows. Whatever the reason, the VCNL4000 is another proximity sensor that caught my eye, so I picked one up from <a href="http://www.sparkfun.com/">Sparkfun</a> on this handy <a href="http://www.sparkfun.com/products/10901">breakout board</a>.</p>
<p>The VCNL4000 looks like it is a single piece of silicon, but it really just is an infrared transmitter and receiver in a package that looks like a chip. Unfortunately, but much like <a href="http://bildr.org/2011/03/various-proximity-sensors-arduino/">many other proximity sensors</a> the VCNL4000 can not easily be used for measuring exact distance. The way it works is that it shines a beam of IR light from an LED, and measures the intensity of light that is bounced pack. But that reading is not linear, so you can&#8217;t say 5cm is X so 10cm is 2X, it may only be 1.2X. Also note that because it is looking at reflected light, the surface of the object the light is reflecting off of will have an impact on the reading. So a reflective surface will read as a higher value than a dark matte surface even at the same distance. </p>
<p>But what makes this part special is that it also incorporates a pretty sensitive ambient light sensor. Also, unlike many other proximity sensors, the VCNL4000 does not have a simple analog output, but instead outputs a 16bit digital reading. So it is much more sensitive (32x) than what the Arduino&#8217;s native analog pins could do.</p>
<h3>Proximity Sensing</h3>
<p>The VCNL4000 data sheet claims a proximity sensing range of 20cm. In reality, I was only seeing a reasonable change inside 10cm, with major change happening within 8cm. Also, 16bits over 20cm is probably hugely overkill, and I doubt you will be able to tell a sub-milimenter difference as the numbers would have you believe. At least not until you get about 3cm away as the sensitivity seems to be exponential. But if you need that kind of result, you probably should get yourself a laser.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/02/VCNL4000_arduino_hookup2.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/02/VCNL4000_arduino_hookup2-400x637.png" alt="" title="VCNL4000_arduino_hookup2" width="400" height="637" class="alignleft size-medium wp-image-2003" /></a>
</div>
</div>
<h3>Ambient Light Sensing</h3>
<p>The ambient light sensor on this thing is really, really good. It&#8217;s very stable and in lower light it was able to pickup very small changes in light. Shadows that I could barely notice myself triggered a noticeable change in the reading.</p>
<p>So if you only need short range proximity sensing, save your self a load of cash and just pick up a <a href="http://bildr.org/2011/03/various-proximity-sensors-arduino/">QRD1114</a>. However, if you need both short-range proximity sensing, and ambient light sensing, this is a really great chip. </p>
<h3>Hooking it up</h3>
<p>The VCNL4000 is an I2C device. I2C is a 2-wire serial connection, so you just need to connect the SDA (Data) and SCL (Clock) lines to your Arduino for communication. On most arduinos SDA is on analog pin 4, and SCL is on analog pin 5. On an arduino mega, SDA is digital 20, and SCL is digital 21. The Leonardo&#8217;s have their own special connections.</p>
<p>The board needs 3.3v to run, but it also needs 5V for the IR led that it uses to check the proximity.</p>
<h3>Code</h3>
<p>Because the board operates on I2C, the code is kinda crazy. Please don&#8217;t ask how it works. I don&#8217;t know that I even know, and there are some bitwise operators on there to complicate it too. But if you just want it to work, here is the code.</p>
<p><b>Note: that the ambient light readings take about 100ms to execute</b></p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="co2">#include &lt;Wire.h&gt;</span>

<span class="co2">#define VCNL4000_ADDRESS 0x13  //I2C Address of the board</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// Serial's used to debug and print data</span>
  Wire.<span class="me1">begin</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// initialize I2C stuff</span>
  initVCNL4000<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//initilize and setup the board</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">unsigned</span> <span class="kw4">int</span> ambientValue <span class="sy0">=</span> readAmbient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//can a tiny bit slow</span>
  <span class="kw4">unsigned</span> <span class="kw4">int</span> proximityValue <span class="sy0">=</span> readProximity<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">Serial</span>.<span class="me1">print</span><span class="br0">&#40;</span>ambientValue<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">Serial</span>.<span class="me1">print</span><span class="br0">&#40;</span><span class="st0">&quot; | &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>proximityValue<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">delay</span><span class="br0">&#40;</span>100<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">//Just here to slow down the printing</span>
  <span class="co1">//note that the readings take about 100ms to execute</span>
<span class="br0">&#125;</span>






<span class="kw4">void</span> initVCNL4000<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">byte</span> temp <span class="sy0">=</span> readVCNLByte<span class="br0">&#40;</span>0x81<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw1">if</span> <span class="br0">&#40;</span>temp <span class="sy0">!=</span> <span class="nu12">0x11</span><span class="br0">&#41;</span><span class="br0">&#123;</span>  <span class="co1">// Product ID Should be 0x11</span>
    <span class="kw3">Serial</span>.<span class="me1">print</span><span class="br0">&#40;</span><span class="st0">&quot;initVCNL4000 failed to initialize&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>temp<span class="sy0">,</span> HEX<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span><span class="kw1">else</span><span class="br0">&#123;</span>
    <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;VNCL4000 Online...&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span> 

  <span class="coMULTI">/*VNCL400 init params
   Feel free to play with any of these values, but check the datasheet first!*/</span>
  writeVCNLByte<span class="br0">&#40;</span>0x84<span class="sy0">,</span> 0x0F<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// Configures ambient light measures - Single conversion mode, 128 averages</span>
  writeVCNLByte<span class="br0">&#40;</span>0x83<span class="sy0">,</span> 15<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// sets IR current in steps of 10mA 0-200mA --&gt; 200mA</span>
  writeVCNLByte<span class="br0">&#40;</span>0x89<span class="sy0">,</span> 2<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// Proximity IR test signal freq, 0-3 - 781.25 kHz</span>
  writeVCNLByte<span class="br0">&#40;</span>0x8A<span class="sy0">,</span> 0x81<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// proximity modulator timing - 129, recommended by Vishay </span>
<span class="br0">&#125;</span>


<span class="kw4">unsigned</span> <span class="kw4">int</span> readProximity<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// readProximity() returns a 16-bit value from the VCNL4000's proximity data registers</span>
  <span class="kw4">byte</span> temp <span class="sy0">=</span> readVCNLByte<span class="br0">&#40;</span>0x80<span class="br0">&#41;</span><span class="sy0">;</span>
  writeVCNLByte<span class="br0">&#40;</span>0x80<span class="sy0">,</span> temp <span class="sy0">|</span> 0x08<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// command the sensor to perform a proximity measure</span>

  <span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span>readVCNLByte<span class="br0">&#40;</span>0x80<span class="br0">&#41;</span><span class="sy0">&amp;</span>0x20<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// Wait for the proximity data ready bit to be set</span>
  <span class="kw4">unsigned</span> <span class="kw4">int</span> data <span class="sy0">=</span> readVCNLByte<span class="br0">&#40;</span>0x87<span class="br0">&#41;</span> <span class="sy0">&lt;&lt;</span> <span class="nu0">8</span><span class="sy0">;</span>
  data <span class="sy0">|=</span> readVCNLByte<span class="br0">&#40;</span>0x88<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw1">return</span> data<span class="sy0">;</span>
<span class="br0">&#125;</span>


<span class="kw4">unsigned</span> <span class="kw4">int</span> readAmbient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// readAmbient() returns a 16-bit value from the VCNL4000's ambient light data registers</span>
  <span class="kw4">byte</span> temp <span class="sy0">=</span> readVCNLByte<span class="br0">&#40;</span>0x80<span class="br0">&#41;</span><span class="sy0">;</span>
  writeVCNLByte<span class="br0">&#40;</span>0x80<span class="sy0">,</span> temp <span class="sy0">|</span> 0x10<span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// command the sensor to perform ambient measure</span>

  <span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span>readVCNLByte<span class="br0">&#40;</span>0x80<span class="br0">&#41;</span><span class="sy0">&amp;</span>0x40<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>  <span class="co1">// wait for the proximity data ready bit to be set</span>
  <span class="kw4">unsigned</span> <span class="kw4">int</span> data <span class="sy0">=</span> readVCNLByte<span class="br0">&#40;</span>0x85<span class="br0">&#41;</span> <span class="sy0">&lt;&lt;</span> <span class="nu0">8</span><span class="sy0">;</span>
  data <span class="sy0">|=</span> readVCNLByte<span class="br0">&#40;</span>0x86<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw1">return</span> data<span class="sy0">;</span>
<span class="br0">&#125;</span>


<span class="kw4">void</span> writeVCNLByte<span class="br0">&#40;</span><span class="kw4">byte</span> address<span class="sy0">,</span> <span class="kw4">byte</span> data<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// writeVCNLByte(address, data) writes a single byte of data to address</span>
  Wire.<span class="me1">beginTransmission</span><span class="br0">&#40;</span>VCNL4000_ADDRESS<span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">write</span><span class="br0">&#40;</span>address<span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">write</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">endTransmission</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>


<span class="kw4">byte</span> readVCNLByte<span class="br0">&#40;</span><span class="kw4">byte</span> address<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="co1">// readByte(address) reads a single byte of data from address</span>
  Wire.<span class="me1">beginTransmission</span><span class="br0">&#40;</span>VCNL4000_ADDRESS<span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">write</span><span class="br0">&#40;</span>address<span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">endTransmission</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  Wire.<span class="me1">requestFrom</span><span class="br0">&#40;</span>VCNL4000_ADDRESS<span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">!</span>Wire.<span class="me1">available</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw4">byte</span> data <span class="sy0">=</span> Wire.<span class="me1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw1">return</span> data<span class="sy0">;</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/vcnl4000-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Temperature With Thermistor + Arduino</title>
		<link>http://bildr.org/2012/11/thermistor-arduino/</link>
		<comments>http://bildr.org/2012/11/thermistor-arduino/#comments</comments>
		<pubDate>Fri, 23 Nov 2012 14:45:55 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[Temperature]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2138</guid>
		<description><![CDATA[
A Thermistor is a thermal-resistor. It&#8217;s just a simple device that changes it&#8217;s resistance based on temperature. If the LRD/Photoresistor is day of of arduino class. The thermistor should be day 1.01. (Can I do that?). If you need precise temperature readings, this is not the part for you. Check out the DS18B20, TMP102, or [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/08/Thermistor.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
<p>A Thermistor is a thermal-resistor. It&#8217;s just a simple device that changes it&#8217;s resistance based on temperature. If the <a href="http://bildr.org/2012/11/photoresistor-arduino/">LRD/Photoresistor</a> is day of of arduino class. The thermistor should be day 1.01. (Can I do that?).</p>
<p><b>If you need precise temperature readings, this is not the part for you. Check out the <a href="http://bildr.org/2011/07/ds18b20-arduino/">DS18B20</a>, <a href="http://bildr.org/2011/01/tmp102-arduino/">TMP102</a>, or <a href="http://bildr.org/2011/02/mlx90614-arduino/">MLX90614</a></b></p>
<p>Thermistors are not that precise or anything, so you wont be able to tell the temperature with it, but if you need to know when the temperature has changed, this will work for you. And on the plus side, they are crazy cheap considering the alternatives, incredibly simple to hookup, and have some of the easiest code ever. You can find these pretty easily at most hobby electronics shops, or just add some to your next <a href="https://www.sparkfun.com/products/250">sparkfun order</a>.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/Thermistor-arduino.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/Thermistor-arduino-400x288.png" alt="" title="Thermistor-arduino" width="400" height="288" class="alignleft size-medium wp-image-2207" /></a></p>
</div>
</div>
<h3>Hooking it up, and why</h3>
<p>The thermistor changes its resistance with temperature so we can measure that change using one of the Arduino&#8217;s analog pins. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 10K resistor). This is called a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a> and divides the 5v between the thermistor and the resistor. </p>
<p>The analog read on your arduino is basically a voltage meter. at 5V (its max) it would read 1023, and at 0v it read 0. So we can measure how much voltage is on the thermistor using the analogRead and we have our reading. </p>
<p>The amount of that 5V that each part gets is proportional to its resistance. So if the the thermistor and the resistor have the same resistance, the 5V is split evenly (2.5V) to each part. (analog reading of 512)</p>
<p>But if the thermistor is really hot and is reading only 1K of resistance, the 10K resistor is going to soak up 10 times as much of that 5V. So the thermistor would only get .45V. (analog reading of 92)</p>
<p>And if it is in the refrigerator, the thermistor may be 40K or resistance, so the thermistor will soak up 4 times as much of that 5V as the 10K resistor. So the thermistor would get 4V. (analog reading of 819)</p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="kw4">int</span> thermistorPin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> thermistorReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>thermistorPin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>thermistorReading<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/thermistor-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sensing A Bend With A Flex Sensor + Arduino</title>
		<link>http://bildr.org/2012/11/flex-sensor-arduino/</link>
		<comments>http://bildr.org/2012/11/flex-sensor-arduino/#comments</comments>
		<pubDate>Fri, 23 Nov 2012 14:40:24 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flex sensor]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2214</guid>
		<description><![CDATA[
We spend so much time talking about sensing things less mechanical, that is is easy to forget the accelerometer isnt the only part in town. The flex sensor is one of those parts often overlooked by the advanced user. But what if you need to check if something bent? Like a finger, or a doll [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/11/flexSensor.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
<p>We spend so much time talking about sensing things less mechanical, that is is easy to forget the accelerometer isnt the only part in town. The flex sensor is one of those parts often overlooked by the advanced user. But what if you need to check if something bent? Like a finger, or a doll arm. (A lot of toy prototypes seem to have this need).</p>
<p>Anytime you need to detect a flex, or bend, a flex sensor is probably the part for you. They come in a few different sizes ( <a href="https://www.sparkfun.com/products/10264">small</a>, <a href="https://www.sparkfun.com/products/8606">large</a>).</p>
<p>The flex sensor is basically a variable resistor that reacts to bends. Unbent it measures about 22KΩ, to 40KΩ when bend 180º. Note that the bend is only detected in one direction and the reading can be a bit shaky, so you will have best results detecting changes of at least 10º.</p>
<p>Also, make sure you don&#8217;t bend the sensor at the base as it wont register as a change, and could break the leads. I always tape some thick board to the base of it to make it wont bend there.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/flex-sensor-arduino.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/flex-sensor-arduino-400x300.png" alt="" title="flex-sensor-arduino" width="400" height="300" class="alignleft size-medium wp-image-2243" /></a></p>
</div>
</div>
<h3>Hooking it up, and why</h3>
<p>The flex sensor changes its resistance when flexed so we can measure that change using one of the Arduino&#8217;s analog pins. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 22K resistor). This is called a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a> and divides the 5v between the flex sensor and the resistor. </p>
<p>The analog read on your arduino is basically a voltage meter. at 5V (its max) it would read 1023, and at 0v it read 0. So we can measure how much voltage is on the flex sensor using the analogRead and we have our reading. </p>
<p>The amount of that 5V that each part gets is proportional to its resistance. So if the the flex sensor and the resistor have the same resistance, the 5V is split evenly (2.5V) to each part. (analog reading of 512)</p>
<p>Just pretend that the the sensor was reading only 1.1K of resistance, the 22K resistor is going to soak up 20 times as much of that 5V. So the flex sensor would only get .23V. (analog reading of 46)</p>
<p>And if we roll the flex sensor around a tibe, the flex sensor may be 40K or resistance, so the flex sensor will soak up 1.8 times as much of that 5V as the 22K resistor. So the flex sensor would get 3V. (analog reading of 614)</p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
<p>In my tests I was getting a reading on the arduino between 512, and 614. So the range isnt the best. But using the <a href="http://arduino.cc/en/Reference/map">map() function</a>, you can convert that to a larger range.</p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="kw4">int</span> flexSensorPin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> flexSensorReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>flexSensorPin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>flexSensorReading<span class="br0">&#41;</span><span class="sy0">;</span>


  <span class="co1">//In my tests I was getting a reading on the arduino between 512, and 614. </span>
  <span class="co1">//Using map(), you can convert that to a larger range like 0-100.</span>
  <span class="kw4">int</span> flex0to100 <span class="sy0">=</span> <span class="kw3">map</span><span class="br0">&#40;</span>flexSensorReading<span class="sy0">,</span> 512<span class="sy0">,</span> 614<span class="sy0">,</span> 0<span class="sy0">,</span> 100<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>flex0to100<span class="br0">&#41;</span><span class="sy0">;</span>

  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/flex-sensor-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Light Reading With LDR + Arduino</title>
		<link>http://bildr.org/2012/11/photoresistor-arduino/</link>
		<comments>http://bildr.org/2012/11/photoresistor-arduino/#comments</comments>
		<pubDate>Fri, 23 Nov 2012 14:32:06 +0000</pubDate>
		<dc:creator>ameyer</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[LDR]]></category>
		<category><![CDATA[Light]]></category>

		<guid isPermaLink="false">http://bildr.org/?p=2134</guid>
		<description><![CDATA[
The LDR (light dependent resistor) also know as the Photo-resistor (and many other things) is supposed to be day 1 of electronics. But I guess I missed the note because I never used one with my arduino maybe until now. So I guess I&#8217;m weird. But the LDR is super cheap, probably one of the [...]
]]></description>
				<content:encoded><![CDATA[<p><img class="noFrame" src="http://bildr.org/blog/wp-content/uploads/2012/08/LDR.jpg"/></p>
<div class="columnBody">
<div class="leftColumn">
<p>The LDR (light dependent resistor) also know as the Photo-resistor (and many other things) is supposed to be day 1 of electronics. But I guess I missed the note because I never used one with my arduino maybe until now. So I guess I&#8217;m weird. But the LDR is super cheap, probably one of the easiest parts to find / use, and certainly has to have the simplest code. You can find these at any electronics store ever I imagine, or do what I did and add a few to your next <a href="https://www.sparkfun.com/products/9088">sparkfun order</a>.</p>
<p><b>If you need precise light measurement check out the <a href="http://bildr.org/2011/06/temt6000_arduino/">TEMT6000</a> or the <a href="http://bildr.org/2011/09/tsl230r-arduino/">TSL230R</a> </b></p>
<p>The LDR / Photo-resistor is basically a very simple light sensor that changes its resistance with light, lowering with more light. You can find these used in everything from the furby to automatic night lights and things like that. The LDR isn&#8217;t very precise, so you cant get a quantitative LUX reading or anything like that. But it is good enough to tell the difference between light and shadow, or know if the light in your room is on/off. So if you just need to know if the light in the room has changed, or someone walked by (casting a shadow) this is your part.</p>
</div>
<div class="rightColumn">
<p><a href="http://bildr.org/blog/wp-content/uploads/2012/11/arduino-LDR-photoresistor1.png"><img src="http://bildr.org/blog/wp-content/uploads/2012/11/arduino-LDR-photoresistor1-400x344.png" alt="" title="arduino-LDR-photoresistor" width="400" height="344" class="alignleft size-medium wp-image-2198" /></a>
</div>
</div>
<h3>Hooking it up, and why</h3>
<p>The LDR changes its resistance with light so we can measure that change using one of the Arduino&#8217;s analog pins. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 10K resistor). This is called a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a> and divides the 5v between the LDR and the resistor. Then we measure how much voltage is on the LDR using the analog read on your arduino, and we have our reading. The amount of that 5V that each part gets is proportional to its resistance.</p>
<p>With the arduino analogRead, at 5V (its max) it would read 1023, and at 0v it read 0.</p>
<p>So if the the LDR and the resistor have the same resistance, the 5V is split evenly (2.5V), to each part. (analogRead of 512)</p>
<p>But if the LDR is hit with a ton of light and is reading only 1K of resistance, the 10K resistor is going to soak up 10 times as much of that 5V. So the LDR would only get .45V (analogRead of 92).</p>
<p>And if it is in a dark room, the LDR may be 40K or resistance, so the LDR will soak up 4 times as much of that 5V as the 10K resistor. So the LDR would get 4V (analogRead of 818).</p>
<h3>Code</h3>
<p>The arduino code for this just could not be easier. We are adding some serial prints and delays to it just so you can easily see the readings, but they dont need to be there if you dont need them.</p>
<div class="codesnip-container" >
<div class="codeHead">
				<a class="copy" href="#">Copy Code</a>
			</div>
<pre class="arduino codesnip" style="font-family:monospace;"><span class="kw4">int</span> LDR_Pin <span class="sy0">=</span> A0<span class="sy0">;</span> <span class="co1">//analog pin 0</span>

<span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw3">Serial</span>.<span class="me1">begin</span><span class="br0">&#40;</span>9600<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw4">int</span> LDRReading <span class="sy0">=</span> <span class="kw3">analogRead</span><span class="br0">&#40;</span>LDR_Pin<span class="br0">&#41;</span><span class="sy0">;</span> 

  <span class="kw3">Serial</span>.<span class="me1">println</span><span class="br0">&#40;</span>LDRReading<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw3">delay</span><span class="br0">&#40;</span>250<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//just here to slow down the output for easier reading</span>
<span class="br0">&#125;</span></pre>
<div class="codeFoot">
				Unless otherwise stated, this code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> &#8211; Please use, change and share it.
			</div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bildr.org/2012/11/photoresistor-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
