<?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>Creating With Code &#187; HowTo</title>
	<atom:link href="http://creatingwithcode.com/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://creatingwithcode.com</link>
	<description>A blog by Robert (Marty) McGuire</description>
	<lastBuildDate>Tue, 17 Aug 2010 18:38:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Automatic MakerBot Camera Pt. 4 &#8211; Updating ReplicatorG</title>
		<link>http://creatingwithcode.com/howto/makerbot-cam-4-repg/</link>
		<comments>http://creatingwithcode.com/howto/makerbot-cam-4-repg/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 19:53:01 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MakerBot]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[g-code]]></category>
		<category><![CDATA[replicatorg]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=201</guid>
		<description><![CDATA[In the previous posts in this series, I hacked up a Canon camera to take pictures with an electronic trigger, built a cable to connect the camera to my MakerBot, and hacked the MakerBot&#8217;s firmware to enable it to trigger the camera in response to commands from the controlling computer. The final step was to [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous posts in this series, I <a href="/howto/makerbot-cam-1-chdk/">hacked up a Canon camera</a> to take pictures with an electronic trigger, <a href="/howto/makerbot-cam-2-wiring/">built a cable</a> to connect the camera to my MakerBot, and <a href="/howto/makerbot-cam-3-firmware/">hacked the MakerBot&#8217;s firmware</a> to enable it to trigger the camera in response to commands from the controlling computer.</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check31.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check31.png" alt="" title="MakerBot camera communications diagram, all done (except the PC)." width="513" height="139" class="alignnone size-full wp-image-212" /></a></p>
<p>The final step was to hack the desktop software that controls the MakerBot &#8211; ReplicatorG.</p>
<h3>What is ReplicatorG?</h3>
<p>From the <a href="http://replicat.org/">ReplicatorG website</a>:</p>
<blockquote><p>[ReplicatorG] is the software that will drive your CupCake CNC, RepRap machine, or generic CNC machine. You can give it a GCode or STL file to process, and it takes it from there. Its cross platform, easily installed, and is based on the familiar Arduino / Processing environments.</p></blockquote>
<p>For my purposes, ReplicatorG provides two things. First, RepG is a user interface for controlling the MakerBot hardware:</p>
<p><a href="http://www.flickr.com/photos/phooky/4604290256/sizes/o/"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/replicator_g_control_panel.png" alt="" title="RepG extruder control panel. Image by phooky, CC-BY-SA." width="426" height="437" class="alignnone size-full wp-image-218" /></a></p>
<p>Second, RepG reads <a href="http://en.wikipedia.org/wiki/G-code">G-code</a> files describing how to build an object, and transmits them to the MakerBot over the USB:</p>
<p><a href="http://www.flickr.com/photos/makerbot/4816221120/sizes/m/"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/repg_gcode.jpg" alt="" title="RepG G-code viewer. Image by makerbot, CC-BY." width="476" height="500" class="alignnone size-full wp-image-220" /></a></p>
<p>Of course, ReplicatorG is open source, and the code is <a href="http://github.com/makerbot/ReplicatorG">available on GitHub</a>!  So, it was simple to clone their repository and start hacking on it myself.</p>
<h3>Camera Control via ReplicatorG</h3>
<p>While it was relatively simple to update the extruder controller firmware to make it camera-aware, ReplicatorG is a bit more complicated.  My first goal was to hack a new &#8220;Camera&#8221; checkbox into the control panel.  Whenever the box was checked, the camera would take pictures. Whenever the box was unchecked, the camera would be idle.</p>
<p>You can find the code required for these changes in <a href="http://github.com/martymcguire/ReplicatorG/commit/6b967b4e7dd115a674c3e223d3abc7119ab44c1a">this commit on GitHub</a>, but I will try to briefly break them down here:</p>
<ul>
<li><strong>Define a new machine</strong>.  In the <code>machines.xml.dist</code> file, I defined an experimental MakerBot configuration named &#8220;EXPERIMENTAL &#8211; Cupcake CNC w/HBP and remote camera&#8221;.  It is essentially a copy of the typical MakerBot configuration with a heated build platform, but in the <code>&lt;tool&gt;</code> definition, I also added a <code>camera="true"</code> attribute.</li>
<li><strong>Update the tool model</strong>. In <code>ToolModel.java</code>, I added code to represent whether the tool has an attached camera, whether the camera is activated, and how to parse the <code>camera</code> attribute out of <code>machines.xml</code>.</li>
<li><strong>Update the machine driver model</strong>.  In <code>Driver.java</code>, <code>DriverBaseImplementation.java</code>, and <code>Sanguino3GDriver.java</code>, I added the definitions and implementations to <code>triggerCamera()</code> and <code>stopTriggeringCamera()</code>.  This is the code that actually sends the <code>TOGGLE_CAMERA</code> serial command to the extruder controller, which I also defined in <code>ToolCommandCode.java</code>.</li>
<li><strong>Update the control panel interface</strong>. In <code>ExtruderPanel.java</code>, I added the code to draw a new label and checkbox named &#8220;Camera&#8221;, if the machine is configured for a camera, and to respond to check/uncheck events by calling <code>triggerCamera()</code> or <code>stopTriggeringCamera()</code>.</li>
</ul>
<h3>Compiling and Running the new ReplicatorG</h3>
<p>Compiling ReplicatorG is pretty simple, so long as you have a reasonable JDK environment and have Ant on your path.  There are basically two steps:
<ol>
<li>Copy <code>machines.xml.dist</code> to <code>machines.xml</code>.</li>
<li>Run the proper <code>dist-linux.sh</code>, <code>dist-mac.sh</code>, or <code>dist-windows.sh</code>.</li>
</ol>
<p>ReplicatorG will be compiled and packaged up into the <code>dist/</code> directory in two forms: an installable package for the chosen platform, and an unpacked version that you can run directly.</p>
<p>Opening up my modified version of ReplicatorG, I selected the &#8220;EXPERIMENTAL &#8211; Cupcake CNC w/HBP and remote camera&#8221; profile from the <strong>Machine -> Driver</strong> menu, opened up the control panel, and was happy to see this:</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/control-panel-cam.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/control-panel-cam.png" alt="" title="RepG control panel... with camera trigger! It's down there, I swear." width="446" height="474" class="alignnone size-full wp-image-234" /></a></p>
<p>After hooking up my camera to the extruder controller&#8217;s <code>D9</code> port, and starting the <code>Remote Button</code> script on the camera, I was able to take pictures by quickly toggling the camera checkbox on and off.  I could also leave the checkbox activated to make the camera take pictures continuously.</p>
<h3>Automatic Triggering with G-codes</h3>
<p>Being able to trigger the camera by hand is all well and good, but my goal was to take pictures automatically at the end of every layer.  To do this, I needed to be able to embed camera trigger commands in the G-code for building each individual object.</p>
<p>Looking at the <a href="http://replicat.org/gcodes">ReplicatorG G-code docs</a>, and the (machine-specific) <a href="http://replicat.org/mcodes">M-code docs</a>, I chose two codes for working with the camera:
<ul>
<li><code>M150</code> &#8211; Trigger Camera</li>
<li><code>M151</code> &#8211; Stop Triggering Camera</li>
</ul>
<p>I may have to change these in the future, as the main ReplicatorG development team claim G- and M-codes for other features, but these work for now.</p>
<p>Modifying ReplicatorG to accept these M-codes (<a href="http://github.com/martymcguire/ReplicatorG/commit/876732b6a70bdaf4389476bfdf240d629ee50017">GitHub commit here</a>) was straightforward: update <code>GCodeParser.java</code> to recognize the codes, and call the appropriate <code>triggerCamera()</code> and <code>stopTriggeringCamera()</code> methods.</p>
<p>I could now construct a G-code file which, when &#8220;built&#8221; in ReplicatorG, would take a picture on demand:<br />
<code><br />
    M150 &nbsp;&nbsp;&nbsp;&nbsp;(trigger the camera)<br />
    G4 P700 &nbsp;(wait 0.7 seconds for the camera to activate)<br />
    M151 &nbsp;&nbsp;&nbsp;&nbsp;(stop triggering)<br />
    G4 P1300 (wait 1.3 seconds for the camera to finish)<br />
</code></p>
<p>Finally, it was time to edit up the G-code for the models I want to photograph.</p>
<p>Typically, G-code is generated by taking a 3D object in STL format and running it through the <a href="http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge">Skeinforge</a> tool.  Skeinforge is a set of Python scripts, which means it is not too difficult to insert your own code.</p>
<p>For now, however, I decided to make a simple hack using a Perl script I wrote called <code>add_camera_events.pl</code>.  It works by looking for <code>(&lt;/layer&gt;)</code> comments, which signal the end of a layer of printing, and inserts lines to:</p>
<ol>
<li>Move to a standard pose (<code>X=0, Y=-45</code>),</li>
<li>Trigger the camera and wait for it to finish, and</li>
<li>Move back to the original position</li>
</ol>
<p>You can find the source for this script in the <a href="http://gist.github.com/489805">add_camera_events.pl gist</a>.  The source for all of my changes to ReplicatorG are on GitHub, in the &#8220;schmarty-camera&#8221; branch of <a href="http://github.com/martymcguire/ReplicatorG/tree/schmarty-camera">my fork of ReplicatorG</a>.</p>
<p>And with that, the computer aspect of this system was finally done!</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check4.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check4.png" alt="" title="Computer, motherboard, extruder controller, camera - all complete!" width="513" class="alignnone size-full wp-image-254" /></a></p>
<h3>Wrap Up</h3>
<p>Phew!  So far I&#8217;ve hacked a camera, wired it to the MakerBot, updated the MakerBot firmware to trigger it, updated ReplicatorG to trigger it, and written a script to update G-code files with camera triggers at the end of each layer.</p>
<p>So&#8230; does it work?  <a href="/makerbot/automatic-makerbot-time-lapse-photography/">You bet</a>!  Stay tuned for more examples and a breakdown video of this whole project in the final post in this series!</p>
<ul>
<li><a href="/howto/makerbot-cam-1-chdk/">Part 1: Remote control camera with CHDK</a></li>
<li><a href="/howto/makerbot-cam-2-wiring/">Part 2: Wiring it up!</a></li>
<li><a href="/howto/makerbot-cam-3-firmware/">Part 3: Updating the MakerBot Firmware</a></li>
<li>Part 4: Updating ReplicatorG [YOU ARE HERE]</li>
<li>Part 5: Printing with the Camera!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/makerbot-cam-4-repg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Space filling with 3D objects using Processing</title>
		<link>http://creatingwithcode.com/howto/space-filling-3d-processing/</link>
		<comments>http://creatingwithcode.com/howto/space-filling-3d-processing/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 02:15:09 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[space filling]]></category>
		<category><![CDATA[STL]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[thingiverse]]></category>
		<category><![CDATA[unlekkerLib]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=160</guid>
		<description><![CDATA[While I know I should be finishing my MakerBot time-lapse camera series, I took some time for another project to play with some Processing. The above image was rendered in Processing, in real time in just couple of minutes! Basically, I wanted to take a simple shape, defined by an SVG path, and fill it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/makerbotiverse3.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/makerbotiverse3.png" alt="" title="MakerBot &quot;M&quot; logo filled with Thingiverse objects." width="462" height="549" class="alignnone size-full wp-image-184" /></a></p>
<p>While I know I should be finishing my <a href="/howto/makerbot-cam-1-chdk/">MakerBot</a> <a href="/howto/makerbot-cam-2-wiring/">time-lapse</a> <a href="/howto/makerbot-cam-3-firmware/">camera</a> <a href="/makerbot/automatic-makerbot-time-lapse-photography/">series</a>, I took some time for another project to play with some <a href="http://processing.org/">Processing</a>.  The above image was rendered in Processing, in real time in just couple of minutes!</p>
<p>Basically, I wanted to take a simple shape, defined by an SVG path, and fill it with images of <a href="http://www.thingiverse.com/thing:1090">3D</a> <a href="http://www.thingiverse.com/thing:3465">objects</a> <a href="http://www.thingiverse.com/thing:3378">loaded</a> <a href="http://www.thingiverse.com/thing:1842">from</a> <a href="http://www.thingiverse.com/thing:1046">STL</a> <a href="http://www.thingiverse.com/thing:1224">files</a>.  Specifically, many wonderful MakerBot-printable objects from <a href="http://www.thingiverse.com/">Thingiverse</a>!</p>
<p>After some Googling around, I found out that this problem is basically a space-filling problem, similar to an excellent Processing sketch named <a href="http://www.openprocessing.org/visuals/?visualID=1811">Scattered Letters</a> by <a href="http://www.openprocessing.org/portal/?userID=1133">Algirdas Rascius</a>, but with a twist.</p>
<p>The basic algorithm is:
<ul>
<li>Load an SVG and render it to an off-screen buffer</li>
<li>Set <code>curr_size</code>, the size that STLs should be rendered, to <code>max_size</code></li>
<li>Choose a random STL model, give it a random orientation, and render it at the current size to an off-screen buffer</li>
<li>Try several times to place this model by giving it a random <code>x</code>,<code>y</code> position and checking it for a good fit:
<ul>
<li>Each non-background pixel of the model&#8217;s off-screen image should fit within the non-background pixels of the SVG&#8217;s off-screen image.</li>
<li>Each non-background pixel of the model&#8217;s off-screen image should NOT overlap with any non-background pixel of the main display.</li>
</ul>
</li>
<li>If a fitting position is found, render the model to the display.</li>
<li>Otherwise, shrink <code>curr_size</code> by a step and choose a new model.</li>
<li>If we drop below <code>min_size</code>, we should stop.</li>
</ul>
<p>You can find the <a href="http://github.com/martymcguire/ThingiverseCollage">code for my sketch, which I call ThingiverseCollage, on GitHub</a>.  To make it work, you&#8217;ll need to follow the installation instructions in the <a href="http://github.com/martymcguire/ThingiverseCollage/blob/master/README">README</a> to install my (very slightly) modified version of the <a href="http://workshop.evolutionzone.com/unlekkerlib/">unlekkerLib for STL loading and rendering</a>.  I modified it to allow rendering to a <code>PGraphics</code> object, since it originally only allowed rendering to the main <code>PApplet</code>.</p>
<p>A note on STL files: unlekkerLib only loads STL files in the binary format.  It chokes dramatically on ASCII STL files, such as those exported from <a href="http://openscad.org/">OpenSCAD</a>.  I was able to use <a href="http://www.pleasantsoftware.com/developer/pleasant3d/index.shtml">Zaggo&#8217;s excellent Pleasant3D</a> to load ASCII STLs and re-save them, which converts them to binary STLs.  As a bonus, Pleasant3D also allows you to orient objects in a way that will make them look most interesting when they are rendered down to 2D in the final image.</p>
<p>An example <code>M.svg</code>, as well as several objects from <a href="http://thingiverse.com/">Thingiverse</a> are included with the code to get started.  To use your own SVGs, I have had good luck using <a href="http://inkscape.org/">Inkscape</a> to draw or import shapes, and save them as the native &#8220;Inkscape SVG&#8221; or &#8220;Plain SVG&#8221; formats.  Some files might require hand-tweaking; for example, if the <code>width</code> and <code>height</code> header values are something like <code>"100%"</code> instead of a pixel value.</p>
<p>There is also some simple configuration in the sketch to allow the export of PDF files.  This is nice because the resulting PDF has full vector data, making it easily rescaled to any size you wish.  Unfortunately, the current PDF renderer for Processing renders <i>each triangle of each STL model</i> as a separate path, generating very complicated vector output, which tends to bring Inkscape to its knees.  I have had some luck with importing those files, rastering them out to PNG at a high resolution (e.g. 600 dpi), and using Inkscape&#8217;s &#8220;Trace Bitmap&#8221; functionality to re-vectorize them, though this requires some cleanup by hand.</p>
<p>Anyway, this has been a fun little diversion for me for the last couple of days.  I hope that you folks find it useful!  Post your awesome pictures in the comments, here!</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/space-filling-3d-processing/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Automatic MakerBot Camera Pt. 3 – Updating the MakerBot Firmware</title>
		<link>http://creatingwithcode.com/howto/makerbot-cam-3-firmware/</link>
		<comments>http://creatingwithcode.com/howto/makerbot-cam-3-firmware/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 00:43:34 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MakerBot]]></category>
		<category><![CDATA[3d printing]]></category>
		<category><![CDATA[firmware]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=144</guid>
		<description><![CDATA[In the previous post in this series, I figured out how to wire up my hacked Canon SD300 with CHDK. I chose to use the &#8220;D9&#8243; port on the Extruder controller board, thinking that should make the software as simple as setting pin 9 to &#8220;HIGH&#8221; for a brief time whenever I wanted to trigger [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous post in this series, I figured out how to <a href="/howto/makerbot-cam-2-wiring/">wire up</a> my <a href="/howto/makerbot-cam-1-chdk/">hacked Canon SD300 with CHDK</a>.  I chose to use the &#8220;D9&#8243; port on the <a href="http://reprap.org/bin/view/Main/Extruder_Controller_2_2#Servo_Headers">Extruder controller board</a>, thinking that should make the software as simple as setting pin 9 to &#8220;HIGH&#8221; for a brief time whenever I wanted to trigger the camera.</p>
<p>The next step was to update the software on the extruder controller so that it could activate (and deactivate) the camera, in response to commands from the motherboard.</p>
<h3><a style="text-decoration: none; color: #000" name="makerbot_comms">An aside on MakerBot communications</a></h3>
<p>The MakerBot electronics ecosystem is comprised of 3 parts: your computer, the <a href="http://reprap.org/wiki/Motherboard_1.2">MakerBot&#8217;s motherboard</a>, and the <a href="http://reprap.org/wiki/Extruder_Controller_2.2">extruder controller board</a>.  Your computer talks to the motherboard via a USB&lt;-&gt;TTL interface (such as this <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9718">FTDI cable from SparkFun</a>).  In turn, the motherboard communicates with the extruder using another serial protocol, <a href="http://en.wikipedia.org/wiki/EIA-485">RS-485</a>, over an ethernet cable.  Finally, the extruder triggers the camera via the custom cable I made in the <a href="/howto/makerbot-cam-2-wiring/">previous post</a>.</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag.png"><img class="size-full wp-image-196 alignnone" style="margin: 10px;" title="MakerBot Communications Diagram - Computer, motherboard, extruder controller, camera" src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag.png" alt="" width="500"/></a></p>
<p>The software for all three components is available on <a href="http://github.com/">the indomitable GitHub</a>.  The software for your computer is called <a href="http://replicat.org/">ReplicatorG</a>, and the source can be found in the <a href="http://github.com/makerbot/ReplicatorG">MakerBot ReplicatorG GitHub repository</a>.  I&#8217;ll talk more about ReplicatorG in the next post in this series.  For now, we want to focus on the <a href="http://github.com/makerbot/G3Firmware">MakerBot G3Firmware GitHub repository</a>, which contains the code for the motherboard (in the <a href="http://github.com/makerbot/G3Firmware/tree/master/SanguinoMaster/">SanguinoMaster</a> subdirectory), and for the extruder (in the <a href="http://github.com/makerbot/G3Firmware/tree/master/ArduinoSlaveExtruder/">ArduinoSlaveExtruder</a> directory).</p>
<p>Browsing through the code, we see that these components use their serial interfaces to send packets, where each command is represented by a number.  The commands for the motherboard can be found in the <a href="http://github.com/makerbot/G3Firmware/blob/master/SanguinoMaster/Commands.h">SanguinoMaster/Commands.h</a>, and those for the extruder can be found in <a href="http://github.com/makerbot/G3Firmware/blob/master/ArduinoSlaveExtruder/PacketProcessor.cpp">ArduinoSlaveExtruder/PacketProcessor.cpp</a>.</p>
<p>To send a message to the extruder &#8211; in this case, to activate or deactivate the camera &#8211; we must create a packet for the motherboard.  The <code>HOST_CMD_TOOL_QUERY</code> code allows us to send the motherboard a packet which it will then pass along to the extruder controller.</p>
<p>That&#8217;s great, because it means the motherboard part of this software hack is done!</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check1.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check1.png" alt="" title="Motherboard - Check!" width="500" height="139" class="alignnone size-full wp-image-208" /></a></p>
<p>In fact, we&#8217;ve already hacked the camera, as well, so we&#8217;re halfway there!</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check2.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check2.png" alt="" title="Camera: Check!" width="513" height="139" class="alignnone size-full wp-image-209" /></a></p>
<h3>Hacking a camera into the extruder controller</h3>
<p>Since the motherboard already does everything we need (passes along packets from the computer to the extruder controller), we only need to update the ArduinoSlaveExtruder code.</p>
<p>To get this to work, I ended up changing the following files:<br />
<a href="http://github.com/martymcguire/G3Firmware/commit/c7ff1ffb5f6004a37a0bcb2b5455403daac447d9#diff-0">ArduinoSlaveExtruder/Configuration.h.dist</a> &#8211; added in configuration options for enabling the camera and setting the pin on which to activate it.<br />
<a href="http://github.com/martymcguire/G3Firmware/commit/c7ff1ffb5f6004a37a0bcb2b5455403daac447d9#diff-2">ArduinoSlaveExtruder/Extruder.h</a> &#8211; added function definitions for turning on/off the camera.<br />
<a href="http://github.com/martymcguire/G3Firmware/commit/c7ff1ffb5f6004a37a0bcb2b5455403daac447d9#diff-1">ArduinoSlaveExtruder/Extruder.cpp</a> &#8211; actually implemented turning on/off the camera.<br />
<a href="http://github.com/martymcguire/G3Firmware/commit/c7ff1ffb5f6004a37a0bcb2b5455403daac447d9#diff-3">ArduinoSlaveExtruder/PacketProcessor.cpp</a> &#8211; implemented the serial command to toggle camera.</p>
<h3>Building and uploading</h3>
<p>If you followed the 4 links above, you&#8217;ll notice that they go to <a href="http://github.com/martymcguire/G3Firmware/">my own G3Firmware GitHub repository</a>.  You can download it yourself to play along by cloning the repository and checking out the <code>ECv2.3rc0-camera</code> branch.</p>
<p>To build the firmware and upload it to the extruder controller, we need some common development tools (make, in this case), and the <a href="http://arduino.cc/">Arduino</a> development environment.  With those things installed, we can compile everything by setting the <code>ARDUINO_HOME</code> environment variable to the path to our Arduino install&#8217;s java directory (e.g. on OS X this would be <code>/Applications/Arduino.app/Contents/Resources/Java/</code>), and simply run <code>make</code>.</p>
<p>Once the firmware has been compiled, we can upload it to the extruder controller by using the USB&lt;-&gt;TTL cable that usually connects the motherboard to our computer.  Plug the cable into the extruder controller, and run the <code>make upload</code> command.  You&#8217;ll need to make sure that <code>ARDUINO_HOME</code> is set, and you will probably need to alter the Makefile to specify the correct serial port, and maybe to update the call to <code>avrdude</code> to include the path to the Arduino avrdude config file.  You can see an example of that in <a href="http://github.com/martymcguire/G3Firmware/commit/0b9c9b09a084f3ad08ccbac7016e82ad3814a3c1">this commit</a>.</p>
<p>Once the firmware is uploaded to the extruder controller, the MakerBot is all set to take pictures!</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check3.png"><img src="http://creatingwithcode.com/wp-content/uploads/2010/07/MB-comms-diag_check3.png" alt="" title="Extruder Controller - Check!" width="513" height="139" class="alignnone size-full wp-image-210" /></a></p>
<p>&#8230; Of course, we still have no way to <strong>tell</strong> the MakerBot to take a picture, so stay tuned for that information in the next update:</p>
<ul>
<li><a href="/howto/makerbot-cam-1-chdk/">Part 1: Remote control camera with CHDK</a></li>
<li><a href="/howto/makerbot-cam-2-wiring/">Part 2: Wiring it up!</a></li>
<li>Part 3: Updating the MakerBot Firmware [YOU ARE HERE]</li>
<li><a href="/howto/makerbot-cam-4-repg/">Part 4: Updating ReplicatorG</a></li>
<li>Part 5: Printing with the Camera!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/makerbot-cam-3-firmware/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Desktop Fabrication Presentation @ Dorkbot Pittsburgh</title>
		<link>http://creatingwithcode.com/howto/dorkbot-pgh-makerbot-presentatio/</link>
		<comments>http://creatingwithcode.com/howto/dorkbot-pgh-makerbot-presentatio/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 01:10:39 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[dorkbot]]></category>
		<category><![CDATA[fabrication]]></category>
		<category><![CDATA[MakerBot]]></category>
		<category><![CDATA[pittsburgh]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=109</guid>
		<description><![CDATA[&#160; On Thursday, March 25th, I spoke about desktop fabrication and the MakerBot Cupcake CNC 3D printer at Dorkbot Pittsburgh. After some slides, I gave a printing demo with my Cupcake, Makerbot #131. You can find my slides above. I&#8217;ll post the video when it becomes available.]]></description>
			<content:encoded><![CDATA[<div style="width:425px" id="__ss_3590812"><object width="500" height="418"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=martymcguire-makerbot-2010-03-25-100329194817-phpapp01&#038;rel=0&#038;stripped_title=desktop-fabrication-marty-mcguire-dorkbot-pittsburgh-march-2010" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=martymcguire-makerbot-2010-03-25-100329194817-phpapp01&#038;rel=0&#038;stripped_title=desktop-fabrication-marty-mcguire-dorkbot-pittsburgh-march-2010" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="418"></embed></object></div>
<div>&nbsp;</div>
<p>On Thursday, March 25th, I spoke about desktop fabrication and the <a href="http://makerbot.com/">MakerBot Cupcake CNC</a> 3D printer at <a href="http://dorkbot.org/dorkbotpgh/">Dorkbot Pittsburgh</a>.  After some slides, I gave a printing demo with my Cupcake, <a href="/makerbot_131">Makerbot #131</a>.  You can find my slides above.  I&#8217;ll post the video when it becomes available.</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/dorkbot-pgh-makerbot-presentatio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic MakerBot Camera Pt. 2 &#8211; Wiring it up!</title>
		<link>http://creatingwithcode.com/howto/makerbot-cam-2-wiring/</link>
		<comments>http://creatingwithcode.com/howto/makerbot-cam-2-wiring/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 01:44:52 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[chdk]]></category>
		<category><![CDATA[MakerBot]]></category>
		<category><![CDATA[makerbot 131]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=83</guid>
		<description><![CDATA[Recently (thanks to the Internet), I figured out how to remote control a digital camera over USB using CHDK. However, if I wanted my MakerBot to be able to automatically control that camera, I needed a way to wire it up! CHDK&#8217;s remote USB trigger functionality works by detecting when it receives power over USB.  [...]]]></description>
			<content:encoded><![CDATA[<p>Recently (thanks to the Internet), I figured out how to <a href="http://creatingwithcode.com/howto/makerbot-cam-1-chdk/">remote control a digital camera over USB using CHDK</a>. However, if I wanted my MakerBot to be able to automatically control that camera, I needed a way to wire it up!</p>
<p>CHDK&#8217;s remote USB trigger functionality works by detecting when it receives power over USB.  This happens when two wires inside the <a href="http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Delectronics&amp;field-keywords=usb+mini+b">USB mini-B</a> cable are connected to power: the red wire gets 5 volts, and the black wire gets connected to ground.</p>
<p><a href="http://reprap.org/bin/view/Main/Extruder_Controller_2_2#Servo_Headers"><img class="alignright" style="margin-left: 5px; float: right" title="Free I/O pins 9 and 10 on the extruder controller board" src="http://farm4.static.flickr.com/3484/3457207368_f7f6af91c0.jpg" alt="" width="300" height="225" /></a>So, I chose to find somewhere on the MakerBot&#8217;s electronics to hook up these power and ground wires such that the MakerBot could control when the red wire receives 5V.  The MakerBot uses <a href="http://store.makerbot.com/electronics/assembled-electronics/generation-3-electronics-mostly-assembled.html">RepRap Generation 3 electronics</a>, and let me tell you, the <a href="http://dev.www.reprap.org/bin/view/Main/Generation3Electronics">gen 3 electronics documentation</a> is fantastic!  Unfortunately, the <a href="http://reprap.org/bin/view/Main/Motherboard_1_2">docs for the main motherboard</a> reveal that there are some <a href="http://reprap.org/bin/view/Main/Motherboard_1_2#I2C_Headers">free I2C headers</a> for connecting serial devices, but no free general I/O pins.</p>
<p>Luckily, the <a href="http://reprap.org/bin/view/Main/Extruder_Controller_2_2#Servo_Headers">extruder controller docs</a> show two free digital pins, conveniently broken out with 5V and ground connections next to them.  These are digital pins D9 and D10.  According to the docs, they are intended for hooking up servo motors, but they would absolutely work for my purposes!</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2010/02/camera_cable.jpg"><img class="size-medium wp-image-88 alignleft" style="margin-right: 5px; float: left" title="Camera cable with ultra-fancy labeling" src="http://creatingwithcode.com/wp-content/uploads/2010/02/camera_cable-300x184.jpg" alt="" width="300" height="184" /></a>The layout for pins D9 and D10 goes (from left to right): I/O pin, 5V, ground.  Since I wanted the data pin itself to provide the 5V, I chose to make a cable using a 3-pin piece of female header, soldering the red wire connecting to the I/O pin (on the left) and the black wire connecting to the ground pin (on the right).  The center pin has no connection.  You can see my &#8220;super fancy&#8221; cable on the left.</p>
<p>I know this post isn&#8217;t particularly about code, so stay tuned for the next parts of this series:</p>
<ul>
<li><a href="/howto/makerbot-cam-1-chdk/">Part 1: Remote control camera with CHDK</a></li>
<li>Part 2: Wiring it up! [YOU ARE HERE]</li>
<li><a href="/howto/makerbot-cam-3-firmware/">Part 3: Updating the MakerBot Firmware</a></li>
<li><a href="/howto/makerbot-cam-4-repg/">Part 4: Updating ReplicatorG</a></li>
<li>Part 5: Updating Skeinforge</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/makerbot-cam-2-wiring/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Automatic MakerBot Camera Pt. 1 &#8211; Remote control camera with CHDK</title>
		<link>http://creatingwithcode.com/howto/makerbot-cam-1-chdk/</link>
		<comments>http://creatingwithcode.com/howto/makerbot-cam-1-chdk/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 02:11:22 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[canon]]></category>
		<category><![CDATA[chdk]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[makerbot 131]]></category>
		<category><![CDATA[point-and-shoot]]></category>
		<category><![CDATA[sd300]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=64</guid>
		<description><![CDATA[One problem with making time-lapse videos of MakerBot prints is the fact that the MakerBot works by moving the build platform (and therefore the object being built) around in the XY plane, resulting in an unwatchable blur. It recently occurred to me that, since the MakerBot is such a hackable platform, I could probably make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://camura.com/s/Be2"><img class="alignright" style="margin-left: 10px; margin-bottom: 2px; float: right;" title="SD300 running CHDK with Remote Control" src="http://static.camura.com/media/images/m/ddb3ff73f26e44cb02c79434d0fd1aed.jpg" alt="" width="240" height="180" /></a>One problem with making <a href="http://www.youtube.com/watch?v=ox_Ng9gDgVE">time-lapse videos</a> of <a href="http://www.youtube.com/watch?v=mcn8Hu8c7qU">MakerBot prints</a> is the fact that the MakerBot works by moving the build platform (and therefore the object being built) around in the XY plane, resulting in an unwatchable blur.</p>
<p>It recently occurred to me that, since the MakerBot is such a hackable platform, I could probably make nice time-lapse videos by taking a picture of each layer.  The idea is to have the MakerBot pose the object after each layer, and trigger a camera to take a snapshot.</p>
<p>When discussing this idea with fellow <a href="http://hackpittsburgh.org/">HackPittsburgh</a> member <a href="http://cibomahto.com/">Matt Mets</a>, he recommended I try out a Canon camera with the <a href="http://chdk.wikia.com/wiki/CHDK">Canon Hack Development Kit (CHDK)</a>.  Making a quick stop on eBay, I soon had an <a href="http://chdk.wikia.com/wiki/SD300">SD300</a> in my hands, ready to be hacked!</p>
<p>I started by <a href="http://chdk.wikia.com/wiki/FAQ#Q._How_can_I_get_the_original_firmware_version_number_of_my_camera.3F">figuring out which firmware my SD300 was running</a>, which told me which <a href="http://mighty-hoernsche.de/bins/ixus40_sd300-100k-0.9.9-872-full.zip">version of CHDK to download</a> for my camera&#8217;s particular model/firmware combo.  Using an SD card reader, I copied the contents of the CHDK zip file onto my camera&#8217;s SD card and followed the instructions to <a href="http://chdk.wikia.com/wiki/FAQ#Q._How_can_I_make_the_CHDK_program_load_automatically_at_startup.3F">make CHDK auto-load</a> when the camera starts up.  I also changed my <a href="http://chdk.wikia.com/wiki/CHDK_firmware_usage">CHDK firmware settings</a> to set &#8220;Disable LCD off&#8221; to &#8220;[Script]&#8220;, so the camera wouldn&#8217;t shut down on its own.</p>
<p>Once CHDK was loaded and configured, I followed the <a href="http://chdk.wikia.com/wiki/USB_Remote_Cable">USB Remote Cable instructions</a> from the CHDK wiki.  The basic idea is to set Enable Remote to on, and load a script that is ready to handle USB remote events.  The one on the wiki page didn&#8217;t work as-is for me, presumably because my camera has half-shoot (i.e. focus and charge flash) and full-shoot (take picture) settings.  Here is the result that worked for me:</p>
<script src="http://gist.github.com/292276.js"></script>
<p>As the script says, I now turn the camera on in record mode, disable the flash, and start the script.  After that, the camera will automatically take a photo whenever I plug in the USB to my computer.</p>
<p>More from this series:</p>
<ul>
<li>Part 1: Remote control camera with CHDK [YOU ARE HERE]</li>
<li><a href="/howto/makerbot-cam-2-wiring/">Part 2: Wiring it up!</a></li>
<li><a href="/howto/makerbot-cam-3-firmware/">Part 3: Updating the MakerBot Firmware</a></li>
<li><a href="/howto/makerbot-cam-4-repg/">Part 4: Updating ReplicatorG</a></li>
<li>Part 5: Printing with the Camera!</li>
</li>
<ul>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/makerbot-cam-1-chdk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Face Detection in Static Images with Python</title>
		<link>http://creatingwithcode.com/howto/face-detection-in-static-images-with-python/</link>
		<comments>http://creatingwithcode.com/howto/face-detection-in-static-images-with-python/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 21:31:22 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[face detection]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[static image]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=16</guid>
		<description><![CDATA[One of the things I&#8217;ve been longing to do with my mobile photo-sharing site Camura is to offer image annotations, like objects and faces.  Over the last couple of years I have been increasingly frustrated by the appearance of face tagging on services like Facebook, and the recent addition of face recognition to iPhoto has [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I&#8217;ve been longing to do with my mobile photo-sharing site <a href="http://camura.com/">Camura</a> is to offer image annotations, like objects and faces.  Over the last couple of years I have been increasingly frustrated by the appearance of face tagging on services like Facebook, and the recent <a href="http://www.apple.com/ilife/iphoto/#faces">addition of face recognition to iPhoto</a> has brought this frustration to the surface once again.  I don&#8217;t even want to do something as complex as face recognition &#8211; I just want to find faces in an image.</p>
<p>Googling for things like &#8220;open source face detector&#8221; doesn&#8217;t come up with much.  The landscape seems to be comprised of mostly expensive for-pay libraries written for Windows, abandoned research projects, and lots of research papers full of equations &#8212; but no code that I could get to run.</p>
<p>To make a long post short, it turns out that Intel&#8217;s <a href="http://sourceforge.net/projects/opencvlibrary/">OpenCV</a> computer vision library comes with a <a href="http://opencv.willowgarage.com/wiki/FaceDetection">face detector</a> example that should work out of the box.  Better yet, there are now some decent <a href="http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/">Python bindings</a> for OpenCV that come pre-packaged with OpenCV for Ubuntu and Debian.  You can install them with:<br />
<code><br />
    $ sudo apt-get install python-opencv<br />
</code></p>
<p>Now, it seems that most OpenCV <a href="http://blog.jozilla.net/2008/06/27/fun-with-python-opencv-and-face-detection/">face detector examples</a> are meant to be run &#8220;live&#8221;, usually taking the image from a webcam and highlighting faces with a red box in real-time.  However, I have a large database of static images that I want to consider individually, and I simply want to save the face coordinates for later use, rather than altering the picture.</p>
<p>So, with a bit more Googling, I found a Python script that I could chop up and use for this purpose, and here is what I came up with:</p>
<script src="http://gist.github.com/67044.js"></script><noscript><code class="gist"><pre></p>
<pre>#!/usr/bin/python

# face_detect.py

# Face Detection using OpenCV. Based on sample code from:
# http://python.pastebin.com/m76db1d6b

# Usage: python face_detect.py &lt;image_file&gt;

import sys, os
from opencv.cv import *
from opencv.highgui import *

def detectObjects(image):
  """Converts an image to grayscale and prints the locations of any
     faces found"""
  grayscale = cvCreateImage(cvSize(image.width, image.height), 8, 1)
  cvCvtColor(image, grayscale, CV_BGR2GRAY)

  storage = cvCreateMemStorage(0)
  cvClearMemStorage(storage)
  cvEqualizeHist(grayscale, grayscale)
  cascade = cvLoadHaarClassifierCascade(
    '/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml',
    cvSize(1,1))
  faces = cvHaarDetectObjects(grayscale, cascade, storage, 1.2, 2,
                             CV_HAAR_DO_CANNY_PRUNING, cvSize(50,50))

  if faces:
    for f in faces:
      print("[(%d,%d) -&gt; (%d,%d)]" % (f.x, f.y, f.x+f.width, f.y+f.height))

def main():
  image = cvLoadImage(sys.argv[1]);
  detectObjects(image)

if __name__ == "__main__":
  main()</pre>
<p></pre></code></noscript>
<p>An example run of the script looks something like this:<br />
<code><br />
    $ python face_detect.py marty_mcguire.jpg<br />
    [(50,36) -&gt; (115,101)]<br />
</code></p>
<p>You can overlay that rectangle on an output image with ImageMagick&#8217;s &#8220;convert&#8221;:<br />
<code><br />
    $ convert marty_mcguire.jpg -stroke red -fill none -draw "rectangle 50,36 115,101" output.jpg<br />
</code></p>
<p>And the output might look something like this:</p>
<p><a href="http://creatingwithcode.com/wp-content/uploads/2009/02/output.jpg"><img class="size-medium wp-image-18" title="My face: detected!" src="http://creatingwithcode.com/wp-content/uploads/2009/02/output.jpg" alt="My face, it has been detected." width="180" height="240" /></a></p>
<p>Pretty fun stuff!</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/face-detection-in-static-images-with-python/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Getting the Boarduino working with OS X Leopard</title>
		<link>http://creatingwithcode.com/howto/getting-the-boarduino-working-with-os-x-leopard/</link>
		<comments>http://creatingwithcode.com/howto/getting-the-boarduino-working-with-os-x-leopard/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 23:57:01 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[boarduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=13</guid>
		<description><![CDATA[I&#8217;ve been into hardware hacking on and off for much of my life, but I&#8217;ve never really had the time and confidence to design and build my own hardware. In recent years, projects like the open source Arduino have been slowly convincing me that I just might be able to do this stuff. When a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been into hardware hacking on and off for much of my life, but I&#8217;ve never really had the time and confidence to design and build my own hardware.  In recent years, projects like the open source <a href="http://arduino.cc/">Arduino</a> have been slowly convincing me that I just might be able to do this stuff.</p>
<p>When a recent <a href="http://blog.makezine.com/archive/2008/06/build_make_a_boarduino.html">Make blog article</a> showed nearly step-by-step instructions for building a breadboard-friendly Arduino clone called the <a href="http://ladyada.net/make/boarduino/index.html">Boarduino</a>, I felt compelled to order one and try to get it working with my new MacBook.</p>
<p>I ordered the DC Boarduino kit from <a href="http://www.adafruit.com/index.php?main_page=index&#038;cPath=19">LadyAda&#8217;s website</a>, along with the USB TTL-232 cable that would connect to my laptop&#8217;s USB port.  I also ordered the 9V power supply on the site to power the Boarduino.</p>
<p>I found building the Boarduino to be pretty easy (=ahem= with only one screwup on my part) thanks to <a href="http://www.ladyada.net/make/boarduino/solder.html">LadyAda&#8217;s detailed instructions</a>.  It was the first soldering project I had done in awhile, so I am happy that it went so well.</p>
<p>I next looked to the <a href="http://www.arduino.cc/en/Guide/MacOSX">Arduino OS X</a> guide for the software download and installation instructions.  I ended up grabbing version 11 of the Arduino software.  After unpacking the .zip file from the site, I installed the FTDI driver and rebooted, then plugged in the Boarduino&#8217;s power and connected it to the laptop via USB.</p>
<p>Next, I double-clicked the Arduino application to start it, and nothing happened.  After messing around with it on the command line for awhile, I determined that it didn&#8217;t like the version of Java I&#8217;m using (I have the 64-bit version of Java 6 as my default).</p>
<p>So, to run the Arduino software, I had to temporarily set my preferred Java version to 5.0 via the Java Preferences panel in /Applications/Utilities/Java/.  Once I had changed my Java version, the Arduino app started right up with a double-click.  Once I was done with the app, I could set my Java preferences back to Java 6.</p>
<p>In the Arduino app, I set it up to communicate with the Boarduino by selecting &#8220;Arduino NG or older w/ ATmega168&#8243; under the Tools | Board menu.  I then opened up the Blink test program under File | Sketchbook | Examples | Digital | Blink.  To load the program onto the Boarduino, I pressed its reset button, then quickly clicked the &#8220;Upload to I/O Board&#8221; button on the interface.</p>
<p>The red LED on the Boarduino blinked rapidly as data was received, then it started blinking slowly as it ran the Blink program!  Hooray!</p>
<p>I&#8217;m excited that it&#8217;s so easy to get something as powerful and versatile as the Boarduino up and running in just a couple of hours.  I&#8217;m going to try and think of a couple of projects for it.  Whatever I do, I&#8217;ll be sure to post about it here.</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/getting-the-boarduino-working-with-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A couple of Leopard configuration tricks</title>
		<link>http://creatingwithcode.com/howto/a-couple-of-leopard-configuration-tricks/</link>
		<comments>http://creatingwithcode.com/howto/a-couple-of-leopard-configuration-tricks/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 23:28:30 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[java 6]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[preferences]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=14</guid>
		<description><![CDATA[I find Google to be a more and more valuable resource as time goes on, especially when seeking knowledge about how to make this new MacBook act like I want it to. One thing I noticed early on was that pressing Tab to move around various interfaces, from Finder dialogs to web pages, would only [...]]]></description>
			<content:encoded><![CDATA[<p>I find Google to be a more and more valuable resource as time goes on, especially when seeking knowledge about how to make this new MacBook act like I want it to.</p>
<p>One thing I noticed early on was that pressing Tab to move around various interfaces, from Finder dialogs to web pages, would only tab to text entry fields.  Coming from a primarily Windows background, I am used to tabbing my way to checkboxes, dropdowns, and buttons in my interfaces, so this crippled Tab navigation quickly became annoying.</p>
<p>Thanks to <a href="http://www.mactips.org/archives/2008/04/30/tab-through-checkboxes-and-radio-buttons-in-safari/">this blog post</a>, I found the option to make Tab move through &#8220;All Controls&#8221; in <span style="font-style: italic;">System Preferences  | Keyboard &amp; Mouse | Keyboard Shortcuts</span></p>
<p>Another big issue I came up against is the weird Java support that comes with OS X.  Because Apple releases their own versions of Java, we OS X users are kind of at their mercy with respect to what we can use and how we can configure it.  You can install Java 6 from <a href="http://developer.apple.com/java/">Apple&#8217;s download page</a>, but Java 1.5 will still run by default.</p>
<p>Apple provides a &#8220;Java Preferences&#8221; configuration utility in /Applications/Utilities/Java/ which lets you change the default version of Java that will be used in browsers and when double-clicking to launch Java apps.  However, this utility doesn&#8217;t change which version of Java will be found by command-line apps in the terminal, such as <a href="http://ant.apache.org/">Apache Ant</a>.</p>
<p>Another blog post <a href="http://www.docuverse.com/blog/donpark/2008/05/01/java-6-on-leopard">to the rescue</a>!  It turns out that you can change your default version of Java for command line apps freely by changing the <code>CurrentJDK</code> and <code>Current</code> symlinks in <code>/System/Library/Frameworks/JavaVM.framework/Versions/.</code> For example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>System<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>JavaVM.framework<span style="color: #000000; font-weight: bold;">/</span>Versions
    <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-fhsv</span> <span style="color: #000000;">1.6</span> CurrentJDK
    <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-fhsv</span> <span style="color: #000000;">1.6</span> Current</pre></div></div>

<p>Hopefully this post will be able to help others (or at least my future self).</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/a-couple-of-leopard-configuration-tricks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up Rails and MySQL on OS X Leopard</title>
		<link>http://creatingwithcode.com/howto/setting-up-rails-and-mysql-on-os-x-leopard/</link>
		<comments>http://creatingwithcode.com/howto/setting-up-rails-and-mysql-on-os-x-leopard/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 23:08:07 +0000</pubDate>
		<dc:creator>Robert McGuire</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://creatingwithcode.com/?p=12</guid>
		<description><![CDATA[I recently purchased a MacBook to use as my primary development system. One of my first plans was to get up and running with Rails on this new machine. Given that Leopard (OS X 10.5) comes with Ruby version 1.8.6 and RubyGems 1.0.1, I thought I would be in good shape, but there were a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently purchased a MacBook to use as my primary development system.  One of my first plans was to get up and running with Rails on this new machine.  Given that Leopard (OS X 10.5) comes with Ruby version 1.8.6 and RubyGems 1.0.1, I thought I would be in good shape, but there were a couple of snags.  Thanks to the power of Google and other people with similar problems, I was able to get it sorted out.  Here&#8217;s what I did:</p>
<ol>
<li>Updated rubygems to 1.1.1 with <code>sudo gem update --system</code></li>
<li>Installed the 32-bit (x86, NOT x86_64) version of MySQL (community edition, of course) via the installer on the <a href="http://dev.mysql.com/downloads/mysql/5.0.html#downloads">MySQL download page</a>.</li>
<li>Installed the native MySQL driver for Ruby (this was tricky, see below)</li>
<li>Finished by installing Rails and its friends via <code>gem install rails</code></li>
</ol>
<p>Getting the speedier native MySQL driver for Ruby installed was tricky for two reasons.  It seems that by default the installer attempts to compile for 4 architectures, so you have to set an environment variable and pass along a parameter to point to the installed copy of MySQL when calling <code>gem</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=”-arch i386” \
   gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> \
   <span style="color: #660033;">--with-mysql-config</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config</pre></div></div>

<p>If you&#8217;ve never seen it before, the &#8216;&#8211;&#8217; after &#8216;gem install mysql&#8217; means that gem should pass along the next arguments to the programs it uses to build the driver.</p>
<p>The reason for installing the 32-bit version of MySQL (on your fancy 64-bit OS and machine!) is that the version of Ruby that ships with Leopard is apparently 32-bit only.  Yikes.</p>
<p>I&#8217;ve noticed several little annoying details like this in getting other things to work &#8220;like I like&#8221; on OS X.  I&#8217;ll probably end up posting more about them in the next couple of posts.</p>
<p>I know that &#8220;how to&#8221; posts of the form &#8220;I wanted to do X, but Y happened.  Finally I fixed it by Z,&#8221; are pretty boring.  Still, I hope they are useful for preserving the knowledge of how to work around these problems, both for myself and for others.</p>
]]></content:encoded>
			<wfw:commentRss>http://creatingwithcode.com/howto/setting-up-rails-and-mysql-on-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
