<?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>TD Moose &#187; Electronics</title>
	<atom:link href="http://www.tdmoose.com/category/electronics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tdmoose.com</link>
	<description>All things moose, and, then some.</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:22:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Improving a Kinetic bike trainer</title>
		<link>http://www.tdmoose.com/2012/02/06/improving-a-kinetic-bike-trainer/</link>
		<comments>http://www.tdmoose.com/2012/02/06/improving-a-kinetic-bike-trainer/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 17:03:57 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=387</guid>
		<description><![CDATA[The Kinetic bike trainer is generally a great device. It allows a bike to be attached easily for indoor training, and it is portable enough to hauled around to be used for pre-race warm-up. My biggest gripe with the unit that I have is that the only way to adjust the tension is to turn [...]]]></description>
			<content:encoded><![CDATA[<p>The Kinetic bike trainer is generally a great device. It allows a bike to be attached easily for indoor training, and it is portable enough to hauled around to be used for pre-race warm-up. My biggest gripe with the unit that I have is that the only way to adjust the tension is to turn the knob at the back. This means that it can&#8217;t be adjusted while riding. Since it often takes several fine adjustments to get the right tension, it means getting off and on the bike to make each adjustment. Also, there is no way to change the adjustment during a workout without dismounting.</p>
<div id="attachment_384" class="wp-caption alignleft" style="width: 160px"><a href="http://www.tdmoose.com/wp-content/uploads/2012/02/kinetic_trainer.jpg"><img class="size-thumbnail wp-image-384" title="Kinetic Trainer" src="http://www.tdmoose.com/wp-content/uploads/2012/02/kinetic_trainer-150x150.jpg" alt="Kinetic Trainer" width="150" height="150" /></a><p class="wp-caption-text">Here&#39;s the unmodified unit. Note the 5-winged adjustment knob.</p></div>
<p>There are models that have a remote tension lever that attaches the the handlebar, but, I don&#8217;t have one of those. Thus was born the idea of using a motor controlled by an Arduino board to turn the knob by pushing buttons mounted on the handlebars. The real trick though was to hook up a motor to the knob. I wanted to avoid modifying the unit, and that included not wanting to drill mounting holes, or use glue on the knob. I tried using Vex robotic parts at first, this worked well enough to prove that the motor was powerful enough to turn the knob, but it was a wobbly contraption, not suitable for more than a proof-of-concept. I searched around for various things at the hardware store. Among them were hex nuts that matched the thread of the adjustment screw. I thought maybe I could use these to create a knob that could be easier to work with than the knob the came with the Kinetic trainer.</p>
<div id="attachment_385" class="wp-caption alignright" style="width: 160px"><a href="http://www.tdmoose.com/wp-content/uploads/2012/02/linkage_in_place.jpg"><img class="size-thumbnail wp-image-385" title="Linkage in Place" src="http://www.tdmoose.com/wp-content/uploads/2012/02/linkage_in_place-150x150.jpg" alt="Linkage in Place" width="150" height="150" /></a><p class="wp-caption-text">Notches in the PVC fit over the knob nicely. The back of the PVC adaptor has enough flat surface to screw the motor coupling plate in place.</p></div>
<p>The item that  offered the most promise was a PVC adaptor. The part is intended to match a 1 3/4&#8243; pipe to a 1/2&#8243; pipe. What interested me is that the thought that the large end could be notched to fit over the knob, and that the small end had flat surfaces that might be sufficient to drill holes for the motor mounting plate. A Dremel tool and file were all I needed to notch the PVC adaptor so that it fit snugly over the knob. As I had hoped, there was enough flat surface to mount the motor securely. One thing I had to do, that I hadn&#8217;t planned was to drill a hole through the side to allow access to the set screw on the motor shaft collar that is on the inside of the tube. With a couple of pieces of flexible metal strap and twine I got the motor unit and PVC adaptor to press against the knob with sufficient pressure. Yes, I said twine. This is still a prototype after all. Imagine if you will . . .yadda,yadda, yadda.</p>
<div id="attachment_383" class="wp-caption alignleft" style="width: 160px"><a href="http://www.tdmoose.com/wp-content/uploads/2012/02/everything_in_place.jpg"><img class="size-thumbnail wp-image-383" title="Everything in Place" src="http://www.tdmoose.com/wp-content/uploads/2012/02/everything_in_place-150x150.jpg" alt="Everything in Place" width="150" height="150" /></a><p class="wp-caption-text">The motor is driven by an Arduino board. Cat5 cable runs to the handlebars for the control buttons.</p></div>
<p>The electronics were the easy part. Arduino has sever digital ports that can drive a PWM controlled-motor. The Vex motor units I have are free running servos that can be driven very easily with the Arduino by using the Servo module. By using a value of approximately 90 in the Servo::write() method, the motor will be stationary. A value of 0-89 will cause the motor to turn in one direction. A value between 91 and 128 will cause it to turn in the opposite direction. Wiring is pretty standard. The black wire from the motor goes to ground. The red wire goes to the motor supply voltage. The white wire goes to the signal port, in this case the digital port 9 on my Arduino board. Controlling the motor is done with two button switches attached to digital ports 5 and 7. Each port is tied to ground with a 10K resistor. Each switch then is tied to the Arduino 5V supply. When pressed, the digital port is pulled up to make the digitalRead(portNumber) method return TRUE.</p>
<div id="attachment_382" class="wp-caption alignright" style="width: 160px"><a href="http://www.tdmoose.com/wp-content/uploads/2012/02/control_buttons.jpg"><img class="size-thumbnail wp-image-382" title="Motor Control Buttons" src="http://www.tdmoose.com/wp-content/uploads/2012/02/control_buttons-150x150.jpg" alt="Motor control buttons" width="150" height="150" /></a><p class="wp-caption-text">The left button decreases the tension. The right button increases it.</p></div>
<p>The Arduino code is very simple. The main loop looks for one of 3 conditions&#8211;left button pressed, right button pressed, or no buttons pressed. If the left button is pressed, then the motor is turned in a direction to decrease the tension (allow the wheel to spin more freely). If the right button is pressed, the motor, spins the opposite direction, increasing tension (making it harder to pedal). If neither button is pushed, then the motor is held stationary.</p>
<p>There are several things that I would change about the code. First, there is no need to continuing writing the motor direction control during the whole button push. It can be done once, when the button is first pressed. The code runs fine as it is, but it is wasting time with continuous writes that do nothing useful. There should also be some sort of debouncing for each switch. Finally, it would be useful to have have some safety limits built in to prevent excessive tightening and loosening. This would likely require a third switch to put put the unit into a calibration mode. Once the calibration mode is turned off, then the unite would only allow a set number of turns in either direction.</p>
<p>Here is the code.</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">#include <span class="sy0">&lt;</span>Servo.<span class="me1">h</span><span class="sy0">&gt;</span></p>
<p><span class="co1">// myservo will later be attached to an Arduino PWM port.</span><br />
Servo myservo<span class="sy0">;</span></p>
<p><span class="co1">// Use these digital ports for the motor control buttons.</span><br />
<span class="kw4">int</span> inc_tension_button <span class="sy0">=</span> <span class="nu0">7</span><span class="sy0">;</span><br />
<span class="kw4">int</span> dec_tension_button <span class="sy0">=</span> <span class="nu0">5</span><span class="sy0">;</span></p>
<p><span class="co1">// In a perfect world, the stop value would be 90.</span><br />
<span class="kw4">int</span> motor_stop <span class="sy0">=</span> <span class="nu0">95</span><span class="sy0">;</span><br />
<span class="kw4">int</span> inc_tension <span class="sy0">=</span> <span class="nu0">140</span><span class="sy0">;</span><br />
<span class="kw4">int</span> dec_tension <span class="sy0">=</span> <span class="nu0">50</span><span class="sy0">;</span></p>
<p><span class="co1">// Store the last state of the motor each time it is changed.</span><br />
<span class="co1">// TODO &#8211; still needs to be implemented.</span><br />
<span class="kw4">int</span> current_dir <span class="sy0">=</span> motor_stop<span class="sy0">;</span></p>
<p><span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Port 9 is a PWM port, so it is suitable for Servo module use.</span><br />
&nbsp; myservo.<span class="me1">attach</span><span class="br0">&#40;</span>9<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">// We are going to read these ports to detect a button press.</span><br />
&nbsp; pinMode<span class="br0">&#40;</span>inc_tension, INPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; pinMode<span class="br0">&#40;</span>dec_tension, INPUT<span class="br0">&#41;</span><span class="sy0">;</span> <br />
<span class="br0">&#125;</span></p>
<p><span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p>&nbsp; <span class="co1">// TODO &#8211; Only issue each motor_control once when state changes.</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> digitalRead<span class="br0">&#40;</span>dec_tension_button<span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; motor_control<span class="br0">&#40;</span>dec_tension<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span> digitalRead<span class="br0">&#40;</span>inc_tension_button<span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; motor_control<span class="br0">&#40;</span>inc_tension<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; motor_control<span class="br0">&#40;</span>motor_stop<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw4">void</span> motor_control<span class="br0">&#40;</span><span class="kw4">int</span> direction<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; myservo.<span class="me1">write</span><span class="br0">&#40;</span>direction<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2012/02/06/improving-a-kinetic-bike-trainer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino controlled LED matrix</title>
		<link>http://www.tdmoose.com/2011/06/11/arduino-controlled-led-matrix/</link>
		<comments>http://www.tdmoose.com/2011/06/11/arduino-controlled-led-matrix/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 00:45:09 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=353</guid>
		<description><![CDATA[Being bored one Winter day, I soldered some LEDs onto small circular breadboard. Here is what the matrix looks like. The anodes of  LEDs were wired in rows and the cathodes in columns. Thus, to turn on an LED, the proper row and column had to be set to high and low voltages. The next task was to [...]]]></description>
			<content:encoded><![CDATA[<p>Being bored one Winter day, I soldered some LEDs onto small circular breadboard.</p>
<p><img class="alignleft size-thumbnail wp-image-354" title="5 x 5 LED Matrix" src="http://www.tdmoose.com/wp-content/uploads/2011/06/4322366073_5eff71b6fe-150x150.jpg" alt="5 x 5 LED Matrix" width="150" height="150" />Here is what the matrix looks like. The anodes of  LEDs were wired in rows and the cathodes in columns. Thus, to turn on an LED, the proper row and column had to be set to high and low voltages. The next task was to hook this up to an Arduino board and create messages by flashing one character at a time. I drew out the characters on paper and then created binary numbers where the digit &#8217;1&#8242; represented an illuminated LED and &#8217;0&#8242; one that was turned off. A full character would look something like this.</p>
<p>&#8216;B00100&#8242;</p>
<p>&#8216;B01010&#8242;</p>
<p>&#8216;B11111&#8242;</p>
<p>&#8216;B10001&#8242;</p>
<p>&#8216;B10001&#8242;</p>
<p>In this case, this is the letter &#8216;A.&#8217;</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;"><span class="coMULTI">/*<br />
*<br />
* ABCs &#8211; Flash a message by displaying one character at a time on a 5 x 5 LED matrix.<br />
*<br />
* Designed for a homebrew LED matrix. LED cathodes are tied together in horizontal rows.<br />
* Anodes are tied together in vertical columns.<br />
*<br />
*/</span></p>
<p>#define numChars <span class="nu0">3</span> <span class="co1">// How many character patterns defined.</span><br />
#define numMsgChars <span class="nu0">3</span> <span class="co1">// How many characters in the message.</span></p>
<p><span class="co1">// The ledDuration and dispCharRepeat control the total time a character is displayed.</span><br />
<span class="co1">// Up to a point, increasing the ledDuration makes the display brighter.</span><br />
<span class="co1">// The tradeoff is more flicker. Adjust both to get a suitable duration with acceptable flicker.</span><br />
#define rowDuration <span class="nu0">750</span> <span class="co1">// How many microseconds to keep a row of LEDs lit.</span><br />
#define dispCharRepeat <span class="nu0">100</span> <span class="co1">// Loop counter for number of times to loop through character display.</span></p>
<p>#define msgDelay <span class="nu0">3000</span> <span class="co1">// How many milliseconds to delay before repeating message.</span></p>
<p><span class="co1">// Each row of bytes are the LED patterns for each row. Digit &#8217;1&#8242; indicates the LED is on; &#8217;0,&#8217; off.</span><br />
<span class="co1">// Left to right corresponds to top to bottom.</span><br />
<span class="co1">// Here is the character &#8216;A,&#8217; for example.</span><br />
<span class="co1">//</span><br />
<span class="co1">// row 0: &nbsp;0 0 1 0 0</span><br />
<span class="co1">// row 1: &nbsp;0 1 0 1 0</span><br />
<span class="co1">// row 2: &nbsp;1 1 1 1 1 &nbsp;Squint hard enough, you might see the character pattern.</span><br />
<span class="co1">// row 3: &nbsp;1 0 0 0 1</span><br />
<span class="co1">// row 4: &nbsp;1 0 0 0 1</span><br />
<span class="kw4">byte</span> pinData<span class="br0">&#91;</span>numChars<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">5</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span><br />
<span class="br0">&#123;</span>B00100,B01010,B11111,B10001,B10001<span class="br0">&#125;</span>, <span class="co1">// A</span><br />
<span class="br0">&#123;</span>B11110,B10001,B11110,B10001,B11110<span class="br0">&#125;</span>, <span class="co1">// B</span><br />
<span class="br0">&#123;</span>B01110,B10001,B10000,B10001,B01110<span class="br0">&#125;</span>, <span class="co1">// C</span><br />
<span class="br0">&#125;</span><span class="sy0">;</span></p>
<p><span class="kw4">byte</span> mask <span class="sy0">=</span> B10000<span class="sy0">;</span><br />
<span class="kw4">int</span> ledPin<span class="br0">&#91;</span>5<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span>7,6,5,4,3<span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Arduino pins assigned to cathodes.</span><br />
<span class="kw4">int</span> rowPin<span class="br0">&#91;</span>5<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span>12,11,10,9,8<span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Arduino pins assigned to anodes.</span><br />
<span class="kw4">int</span> dispChar<span class="br0">&#91;</span>numMsgChars<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#123;</span>0,1,2<span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// Show the above character in this order.</span></p>
<p><span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw4">int</span> i<span class="sy0">;</span><br />
&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>i<span class="sy0">&lt;</span><span class="nu0">5</span><span class="sy0">;</span>i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// Loop through rowPin and ledPin to set modes and initial values to keep all LEDs off.</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; pinMode<span class="br0">&#40;</span>ledPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; pinMode<span class="br0">&#40;</span>rowPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="co1">// Since these are LEDs, they will only glow when the rowPin is LOW and the ledPin is HIGH.</span><br />
&nbsp; &nbsp; <span class="co1">// Start with every row and LED turned &quot;off&quot;.</span><br />
&nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>rowPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, HIGH<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>ledPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw4">int</span> i<span class="sy0">;</span> <span class="co1">// Letter repetition counter.</span><br />
&nbsp; <span class="kw4">int</span> dispCharNum<span class="sy0">;</span> <span class="co1">// Letter array counter.</span><br />
&nbsp; <span class="kw4">int</span> pinVal<span class="sy0">;</span></p>
<p>&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>dispCharNum<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>dispCharNum<span class="sy0">&lt;</span>numMsgChars<span class="sy0">;</span>dispCharNum<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// Loop through each character in the message.</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>i<span class="sy0">&lt;</span>dispCharRepeat<span class="sy0">;</span>i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// Display character for a while.</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; showLetter<span class="br0">&#40;</span>dispCharNum<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; delay<span class="br0">&#40;</span>msgDelay<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw4">void</span> showLetter<span class="br0">&#40;</span><span class="kw4">int</span> dispCharNum<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw4">int</span> i<span class="sy0">;</span> <span class="co1">// LED position pin counter.</span><br />
&nbsp; <span class="kw4">int</span> j<span class="sy0">;</span> <span class="co1">// LED row counter.</span><br />
&nbsp; <span class="kw4">int</span> pinVal<span class="sy0">;</span> </p>
<p>&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>j<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>j<span class="sy0">&lt;</span><span class="nu0">5</span><span class="sy0">;</span>j<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// for each row</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>i<span class="sy0">&lt;</span><span class="nu0">5</span><span class="sy0">;</span>i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// Loop through each LED in the row.</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; pinVal <span class="sy0">=</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>mask<span class="sy0">&gt;&gt;</span>i<span class="br0">&#41;</span> <span class="sy0">&amp;</span> pinData<span class="br0">&#91;</span>dispChar<span class="br0">&#91;</span>dispCharNum<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#91;</span>j<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">?</span> HIGH <span class="sy0">:</span> LOW<span class="sy0">;</span> <span class="co1">// Bit shift mask and bitwise AND to pinData.</span><br />
&nbsp; &nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>ledPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, pinVal<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// if pinVal is 1, LED will be ON; if 0, OFF.</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>rowPin<span class="br0">&#91;</span>j<span class="br0">&#93;</span>, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">// Set the rowPin to LOW so it can be the &quot;ground&quot; pin for the LED. &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; delayMicroseconds<span class="br0">&#40;</span>rowDuration<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Keep the LED on long enough to be bright without flickering.</span><br />
&nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>rowPin<span class="br0">&#91;</span>j<span class="br0">&#93;</span>, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Set rowPin HIGH so it is no longer a ground pin.</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>i<span class="sy0">&lt;</span><span class="nu0">5</span><span class="sy0">;</span>i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="co1">// Loop through each LED in the row.</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; digitalWrite<span class="br0">&#40;</span>ledPin<span class="br0">&#91;</span>i<span class="br0">&#93;</span>, LOW<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Turn off the LED.</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; <span class="br0">&#125;</span></p>
<p><span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2011/06/11/arduino-controlled-led-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Side glow cable with LEDs</title>
		<link>http://www.tdmoose.com/2009/11/05/side-glow-cable-with-leds/</link>
		<comments>http://www.tdmoose.com/2009/11/05/side-glow-cable-with-leds/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 01:44:47 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fiber optic]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[side glow]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=172</guid>
		<description><![CDATA[Many projects require illumination.  An LED is often a good choice because it can be bright while using a minimum of current.  An ultra bright LED can even drive enough light through short lengths of side glow fiber optic cable.  This cable is flexible plastic cable with a reflective core to direct light to the [...]]]></description>
			<content:encoded><![CDATA[<p>Many projects require illumination.  An LED is often a good choice because it can be bright while using a minimum of current.  An ultra bright LED can even drive enough light through short lengths of side glow fiber optic cable.  This cable is flexible plastic cable with a reflective core to direct light to the side, as opposed to simply transmitting the light to the end of the cable.  While it is designed to be used with bright halogen bulbs that push light through hundreds of feet of cable, I was interested to see how well an LED could work with just a few feet of cable.</p>
<p>My wife and I are interested in making safety clothing for night bicycle riding and thought this might be useful.  We ordered a five foot section of 3mm wide cable from <a href="http://www.fiberopticproducts.com/Sideglow.htm">here</a>. Once I had the cable in hand, I attached a bright red LED to each end with shrink tubing.</p>
<div id="attachment_174" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-174" href="http://www.tdmoose.com/?attachment_id=174"><img class="size-thumbnail wp-image-174" title="End connections" src="http://www.tdmoose.com/wp-content/uploads/2009/11/end_connectors-150x150.jpg" alt="End connections" width="150" height="150" /></a><p class="wp-caption-text">End connections</p></div>
<p>A quick test shows that two LEDs provides a fairly even glow along the entire length of the tube.  Each LED was rated to deliver 18,000 millicandelas of light. </p>
<div id="attachment_173" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-173" href="http://www.tdmoose.com/?attachment_id=173"><img class="size-thumbnail wp-image-173" title="Two LEDs powered up" src="http://www.tdmoose.com/wp-content/uploads/2009/11/two_leds-150x150.jpg" alt="Two LEDs  powered up" width="150" height="150" /></a><p class="wp-caption-text">Two LEDs  powered up</p></div>
<p>This looks like it could be used on a bicycle helmet to provide a flashing illumination.  More to come as we experiment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/11/05/side-glow-cable-with-leds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improving a book light</title>
		<link>http://www.tdmoose.com/2009/10/28/improving-a-book-light/</link>
		<comments>http://www.tdmoose.com/2009/10/28/improving-a-book-light/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 02:43:04 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=156</guid>
		<description><![CDATA[I love to read.  Often, I use a portable light that clips onto the book.  It works OK, but two things bugged me about it.  First, it required four AA batteries.  Second, it used an incandescent bulb that is bright, but which produced glare and hot spots on the page. I had been experimenting with [...]]]></description>
			<content:encoded><![CDATA[<p>I love to read.  Often, I use a portable light that clips onto the book.  It works OK, but two things bugged me about it.  First, it required four AA batteries.  Second, it used an incandescent bulb that is bright, but which produced glare and hot spots on the page.</p>
<div id="attachment_153" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-153" href="http://www.tdmoose.com/?attachment_id=153"><img class="size-thumbnail wp-image-153" title="Original unit" src="http://www.tdmoose.com/wp-content/uploads/2009/10/original_bottom-150x150.jpg" alt="Original bottom view" width="150" height="150" /></a><p class="wp-caption-text">Original bottom view</p></div>
<p>I had been experimenting with a simple circuit called a Joule Thief.  This circuit boosts a DC voltage to a higher voltage.  It&#8217;s is easy to make with easy to obtain parts.  The Web is full of plans for these devices.  The advantage for this project, is that such a circuit can drive a bright white LED from a single 1.5 Volt battery.  I figured that I could easily fit the circuitry and a single AAA battery into the battery compartment of the book light.  This would save batteries and provide a more even light across the page of a book.</p>
<div id="attachment_150" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-150" href="http://www.tdmoose.com/?attachment_id=150"><img class="size-thumbnail wp-image-150" title="Joule Thief" src="http://www.tdmoose.com/wp-content/uploads/2009/10/jewel_thief-150x150.jpg" alt="Joule Thief" width="150" height="150" /></a><p class="wp-caption-text">Joule Thief</p></div>
<p>I replaced the incandescent bulb with a bright white LED that I encased in aquarium sealant inside of a short length of clear plastic tubing.  This helped to diffuse the light along the approximately two inches of tubing that the LED was attached to.  Here&#8217;s the final assembly and it&#8217;s use.</p>
<div id="attachment_154" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-154" href="http://www.tdmoose.com/?attachment_id=154"><img class="size-thumbnail wp-image-154" title="Ready to use" src="http://www.tdmoose.com/wp-content/uploads/2009/10/finished-150x150.jpg" alt="Ready to use" width="150" height="150" /></a><p class="wp-caption-text">Ready to use</p></div>
<div id="attachment_149" class="wp-caption alignnone" style="width: 160px"><a rel="attachment wp-att-149" href="http://www.tdmoose.com/?attachment_id=149"><img class="size-thumbnail wp-image-149" title="Modified lamp in use" src="http://www.tdmoose.com/wp-content/uploads/2009/10/in_use-150x150.jpg" alt="Modified lamp in use" width="150" height="150" /></a><p class="wp-caption-text">Modified lamp in use</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/10/28/improving-a-book-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vex Servo Motor</title>
		<link>http://www.tdmoose.com/2009/09/22/vex-servo-motor/</link>
		<comments>http://www.tdmoose.com/2009/09/22/vex-servo-motor/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 02:25:12 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[555 timer]]></category>
		<category><![CDATA[pwm]]></category>
		<category><![CDATA[servo]]></category>
		<category><![CDATA[vex]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=120</guid>
		<description><![CDATA[Vex servo motors have a lot of good features. They are compact, powerful, and easy to mount and connect to things like gear shafts, beams, levers. I&#8217;ve been using micro controllers to operate these in previous projects, but decided to go old school and use a 555 timer. I really just want to do something [...]]]></description>
			<content:encoded><![CDATA[<p>Vex servo motors have a lot of good features.  They are compact, powerful, and easy to mount and connect to things like gear shafts, beams, levers.  I&#8217;ve been using micro controllers to operate these in previous projects, but decided to go old school and use a 555 timer. I really just want to do something to try out my new USB oscilloscope.  I found this page with a couple of good plans.</p>
<p><a href="http://wolfstone.halloweenhost.com/Motors/svoint_RCServos.html">wolfstone.halloweenhost.com</a></p>
<p><img class="alignnone" title="Simple Pulse Width Modulator Using a 555 Timer" src="http://wolfstone.halloweenhost.com/Motors/svoint_Ron555.gif" alt="" width="354" height="276" /></p>
<p>Breadboarding this was fairly easy and took just a few minutes.  I keep a lot of components around with breadboard wire already soldered, so that makes prototyping a lot faster.<br />
<a rel="attachment wp-att-121" href="http://www.tdmoose.com/?attachment_id=121"><img class="alignnone size-thumbnail wp-image-121" title="servo_555_breadboarded" src="http://www.tdmoose.com/wp-content/uploads/2009/09/servo_555_breadboarded-150x150.jpg" alt="servo_555_breadboarded" width="150" height="150" /></a></p>
<p>Before I attached the motor, I verified that the circuit was performing as needed.  With the oscilloscope set to show 5 ms per division I could measure the minimum pulse width of 1.15 ms and a maximum width of 2.75 ms.</p>
<p><a rel="attachment wp-att-129" href="http://www.tdmoose.com/?attachment_id=129"><img class="alignnone size-thumbnail wp-image-129" title="Minimum Pulse Width" src="http://www.tdmoose.com/wp-content/uploads/2009/09/min_pulse_width-150x150.jpg" alt="Minimum Pulse Width" width="150" height="150" /></a> <a rel="attachment wp-att-130" href="http://www.tdmoose.com/?attachment_id=130"><img class="alignnone size-thumbnail wp-image-130" title="Maximum Pulse Width" src="http://www.tdmoose.com/wp-content/uploads/2009/09/max_pulse_width-150x150.jpg" alt="Maximum Pulse Width" width="150" height="150" /></a></p>
<p>This seemed good enough to try, so I plugged in the motor.  The black wire is ground, the red (or orange) wire is positive, and the white wire is the signal (pin 3 on the 555).    I had nearly the full 100 degree rotation in the motor as I turned to potentiometer shaft back and forth from minimum to maximum.</p>
<p>Just for fun, I substituted a flex sensor for the potentiometer.  Not quite the same amount of rotation, but, I didn&#8217;t bother changing any other component values.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=6510788&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=6510788&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/6510788">Servo Motor with Flex Sensor</a> from <a href="http://vimeo.com/user2131064">Patrick Lewis</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/09/22/vex-servo-motor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taking apart a Flip Ultra 30</title>
		<link>http://www.tdmoose.com/2009/07/27/taking-apart-a-flip-ultra-30/</link>
		<comments>http://www.tdmoose.com/2009/07/27/taking-apart-a-flip-ultra-30/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 15:53:16 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[disassembly]]></category>
		<category><![CDATA[flip]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=92</guid>
		<description><![CDATA[The Flip camera is great and cheap enough to risk destroying it.  Broken down to its bare bones, it is still a little bigger than its predecessor, the  Pure Digital One-use camera. However, the built in USB port and connector, and the ability to connect the Flip to a PC without needing the hack it [...]]]></description>
			<content:encoded><![CDATA[<p>The Flip camera is great and cheap enough to risk destroying it.  Broken down to its bare bones, it is still a little bigger than its predecessor, the <a href="http://www.prnewswire.com/cgi-bin/stories.pl?ACCT=109&amp;STORY=/www/story/06-06-2005/0003818095&amp;EDATE"> Pure Digital One-use camera.</a> However, the built in USB port and connector, and the ability to connect the Flip to a PC without needing the hack it to access stored videos, makes it more useful in the long run.  In short, a great camera for projects that need small, light, durable video recording hardware.<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/vUUEmP-bFRk&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/vUUEmP-bFRk&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/07/27/taking-apart-a-flip-ultra-30/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Re-inventing the scale.</title>
		<link>http://www.tdmoose.com/2009/02/07/38/</link>
		<comments>http://www.tdmoose.com/2009/02/07/38/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 03:11:27 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=38</guid>
		<description><![CDATA[Must have been a long winter stuck inside to try something like this. The idea was to make a scale using a couple of pennies and conductive foam used for packing electronic parts. The first thing was to solder some wire onto pennies. I used a torch instead of a soldering iron because pennies can [...]]]></description>
			<content:encoded><![CDATA[<p>Must have been a long winter stuck inside to try something like this.  The idea was to make a scale using a couple of pennies and conductive foam used for packing electronic parts.  The first thing was to solder some wire onto pennies.  I used a torch instead of a soldering iron because pennies can soak up a lot of heat.</p>
<div id="attachment_36" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-36" title="pennies1" src="http://www.tdmoose.com/wp-content/uploads/2009/02/pennies1.jpg" alt="Pennies with hookup wire soldered to them.  Foam is packing from a power MOSFET." width="300" height="210" /><p class="wp-caption-text">Pennies with hookup wire soldered to them.  Foam is packing from a power MOSFET.</p></div>
<p>The next step was cut some plexiglass sheets and then use some double stick tape to attach a penny to each sheet.  Then I bolted the two sheets together, presssing the foam in between.  Here&#8217;s the assembled unit.</p>
<div id="attachment_37" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-37" title="assembled" src="http://www.tdmoose.com/wp-content/uploads/2009/02/assembled.jpg" alt="Platform assembled, and hooked up to ohmmeter to test base resistance." width="300" height="214" /><p class="wp-caption-text">Platform assembled, and hooked up to ohmmeter to test base resistance.</p></div>
<p>This setup didn&#8217;t work out so well as a scale.  Heavier objects placed on the scale took a long time to reach a stable value.  I figure that the foam continued to compress slightly for two minutes or more.  Also, it took a similar amout of time for the scale to return to it&#8217;s base value.</p>
<p>This arrangement seems to work best not as a scale, but as a pressure pad, particularly as a pressure-relief pad.  For example, it might work well to sense when an object, such as a book, is lifted.  Don&#8217;t anyone dare try to steal my &#8220;Programming Python book!&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/02/07/38/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Power MOSFET tutorial</title>
		<link>http://www.tdmoose.com/2009/02/03/power-mosfet-tutorial/</link>
		<comments>http://www.tdmoose.com/2009/02/03/power-mosfet-tutorial/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 17:48:38 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=22</guid>
		<description><![CDATA[Best short description of how to use power MOSFETS that I&#8217;ve ever found. Now I know why the power sucking pig of an electomagnet I made from hookup wire and a nail is so hard to drive with a power MOSFET. Also, shows why sometimes you are better off just buying controller chips that do [...]]]></description>
			<content:encoded><![CDATA[<p>Best short description of how to use<br />
<a href="http://nutsvolts.texterity.com/nutsvolts/200901/?folio=50"> power MOSFETS</a> that I&#8217;ve ever found.</p>
<p>Now I know why the power sucking pig of an electomagnet I made from hookup wire and a nail is so hard to drive with a power MOSFET.</p>
<p>Also, shows why sometimes you are better off just buying controller chips that do the job you want than to try to roll the circuitry yourself with discreet components.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/02/03/power-mosfet-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino controlled arm</title>
		<link>http://www.tdmoose.com/2009/01/30/arduino-controlled-arm/</link>
		<comments>http://www.tdmoose.com/2009/01/30/arduino-controlled-arm/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 15:59:19 +0000</pubDate>
		<dc:creator>tdmoose</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://www.tdmoose.com/?p=5</guid>
		<description><![CDATA[Controlling 3 motors with an Arduino board. I dug out an old robot arm kit that I had built a long time ago. It was originally operated by push buttons for each motor with a slide switch to reverse the polarity of the current and thus the direction of the motor. With an Arduino module, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Controlling 3 motors with an Arduino board.</strong></p>
<p>I dug out an old robot arm kit that I had built a long time ago. It was originally operated by push buttons for each motor with a slide switch to reverse the polarity of the current and thus the direction of the motor.</p>
<p>With an Arduino module, a couple of H-bridge chips, and a bit of surfing for ideas, I managed to automate it to drop a washer in a small container. The main idea comes from <a href="http://itp.nyu.edu/physcomp/Labs/DCMotorControl">this page</a> page, which describes how to hook up and control one motor. Learning to control two motors is largely inspired by <a href="http://www.me.umn.edu/courses/me2011/robot/technotes/L293/L293hookup.gif">this diagram</a>.</p>
<p>Here it is in action. I had bigger plans for what it would do, but, it is after all, just a cheap kit with plastic parts. The jaws barely have enough grip to hold a small washer. It is a good proof of concept for controlling multiple motors with a single arduino board.</p>
<p><strong><br />
<object height="256" width="320" codebase="http://www.apple.com/qtactivex/qtplugin.cab" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"><param value="http://ww2.tdmoose.com/robo_arm/robot_arm_drop_washer.mov" name="src"/><param value="false" name="autoplay"/><param width="320" height="256" value="video/quicktime" name="type"/><embed height="256" width="320" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" autoplay="false" src="http://ww2.tdmoose.com/robo_arm/robot_arm_drop_washer.mov"/><br />
</object><br />
</strong></p>
<p><img class="alignnone" title="Breadboard construction" src="http://ww2.tdmoose.com/robo_arm/IMG_2375.jpg" alt="" width="307" height="230" /></p>
<p><img class="alignnone" title="3 Motor Schematic" src="http://ww2.tdmoose.com/robo_arm/3_motor_schematic.jpg" alt="" width="540" height="377" /></p>
<p><strong>Wiring code for robot arm</strong></p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;"><span class="kw4">int</span> motor1Pin1 <span class="sy0">=</span> <span class="nu0">3</span><span class="sy0">;</span> &nbsp; &nbsp;<span class="co1">// H-bridge leg 1</span><br />
<span class="kw4">int</span> motor1Pin2 <span class="sy0">=</span> <span class="nu0">4</span><span class="sy0">;</span> &nbsp; &nbsp;<span class="co1">// H-bridge leg 2</span><br />
<span class="kw4">int</span> motor1SpeedPin <span class="sy0">=</span> <span class="nu0">9</span><span class="sy0">;</span> &nbsp; &nbsp; <span class="co1">// H-bridge enable pin</span><br />
<span class="kw4">int</span> motor2Pin1 <span class="sy0">=</span> <span class="nu0">5</span><span class="sy0">;</span><br />
<span class="kw4">int</span> motor2Pin2 <span class="sy0">=</span> <span class="nu0">6</span><span class="sy0">;</span><br />
<span class="kw4">int</span> motor2SpeedPin <span class="sy0">=</span> <span class="nu0">10</span><span class="sy0">;</span><br />
<span class="kw4">int</span> motor3Pin1 <span class="sy0">=</span> <span class="nu0">7</span><span class="sy0">;</span><br />
<span class="kw4">int</span> motor3Pin2 <span class="sy0">=</span> <span class="nu0">8</span><span class="sy0">;</span><br />
<span class="kw4">int</span> motor3SpeedPin <span class="sy0">=</span> <span class="nu0">11</span><span class="sy0">;</span></p>
<p><span class="kw4">int</span> ledPin <span class="sy0">=</span> <span class="nu0">13</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp;<span class="co1">//LED</span></p>
<p><span class="kw4">void</span> setup<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co1">// set all the other pins you&#8217;re using as outputs:</span><br />
pinMode<span class="br0">&#40;</span>motor1Pin1, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor1Pin2, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor1SpeedPin, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor2Pin1, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor2Pin2, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor2SpeedPin, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor3Pin1, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor3Pin2, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span><br />
pinMode<span class="br0">&#40;</span>motor3SpeedPin, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>pinMode<span class="br0">&#40;</span>ledPin, OUTPUT<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// set speedPin high so that motor can turn on:</span><br />
digitalWrite<span class="br0">&#40;</span>motor1SpeedPin, HIGH<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2SpeedPin, HIGH<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor3SpeedPin, HIGH<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// blink the LED 3 times. This should happen only once.</span><br />
<span class="co1">// if you see the LED blink three times, it means that the module</span><br />
<span class="co1">// reset itself,. probably because the motor caused a brownout</span><br />
<span class="co1">// or a short.</span><br />
blink<span class="br0">&#40;</span>ledPin, 3, 100<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw4">void</span> loop<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
delay<span class="br0">&#40;</span>5000<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin1, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Arm up</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>1000<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor3Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">// Arm left</span><br />
digitalWrite<span class="br0">&#40;</span>motor3Pin2, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">//</span><br />
delay<span class="br0">&#40;</span>2500<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor3Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor2Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Arm down</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>1100<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor1Pin1, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// open jaws</span><br />
digitalWrite<span class="br0">&#40;</span>motor1Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>4000<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor1Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor2Pin1, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Arm up</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>1000<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor3Pin1, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Arm right</span><br />
digitalWrite<span class="br0">&#40;</span>motor3Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>2000<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor3Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>digitalWrite<span class="br0">&#40;</span>motor2Pin1, LOW<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1">// Arm down</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, HIGH<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp; <span class="co1">//</span><br />
delay<span class="br0">&#40;</span>1100<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>motor2Pin2, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>500<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="coMULTI">/*<br />
blinks an LED<br />
*/</span><br />
<span class="kw4">void</span> blink<span class="br0">&#40;</span><span class="kw4">int</span> whatPin, <span class="kw4">int</span> howManyTimes, <span class="kw4">int</span> milliSecs<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span><br />
<span class="kw1">for</span> <span class="br0">&#40;</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&amp;</span>lt<span class="sy0">;</span> howManyTimes<span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
digitalWrite<span class="br0">&#40;</span>whatPin, HIGH<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>milliSecs<span class="sy0">/</span>2<span class="br0">&#41;</span><span class="sy0">;</span><br />
digitalWrite<span class="br0">&#40;</span>whatPin, LOW<span class="br0">&#41;</span><span class="sy0">;</span><br />
delay<span class="br0">&#40;</span>milliSecs<span class="sy0">/</span>2<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tdmoose.com/2009/01/30/arduino-controlled-arm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://ww2.tdmoose.com/robo_arm/robot_arm_drop_washer.mov" length="2014640" type="video/quicktime" />
		</item>
	</channel>
</rss>

