<?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>FettesPS &#187; Arduino</title>
	<atom:link href="http://www.fettesps.com/category/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fettesps.com</link>
	<description>Fettes Programming Solutions</description>
	<lastBuildDate>Sun, 22 Jan 2012 18:21:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Arduino and the USBTinyISP</title>
		<link>http://www.fettesps.com/arduino-and-the-usbtinyisp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=arduino-and-the-usbtinyisp</link>
		<comments>http://www.fettesps.com/arduino-and-the-usbtinyisp/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 03:02:27 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ardiuno]]></category>
		<category><![CDATA[ATmega]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[isp]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=1732</guid>
		<description><![CDATA[I&#8217;ve been monkeying around with different ways of uploading the sketches and bootloaders to ATmega chips and one of those ways is with the USBTinyISP which I picked up for about $10 on eBay. Even though once my bootloader was installed I never really needed to use the ISP programmer on my Arduino again I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been monkeying around with different ways of uploading the sketches and bootloaders to ATmega chips and one of those ways is with the USBTinyISP which I picked up for about $10 on eBay. Even though once my bootloader was installed I never really needed to use the ISP programmer on my Arduino again I did find it was useful for programming chips when I had it bread-boarded out. To do that, I had to make a few tweaks to my config files, which were the following on my various computers:</p>
<p>Linux: /usr/share/arduino/hardware/arduino/boards.txt<br />
Windows 7: C:\Program Files (x86)\Arduino\hardware\arduino\boards.txt<br />
Windows XP: C:\Program Files\Arduino-0022\hardware\arduino\boards.txt</p>
<p>With my favourite text editor I openned them up and appended the following lines:</p>
<pre class="brush: plain; title: ; notranslate">
##############################################################

atmega168bb.name=ATmega168 on a breadboard (8 MHz internal clock)

atmega168bb.upload.protocol=stk500
atmega168bb.upload.maximum_size=14336
atmega168bb.upload.speed=57600

atmega168bb.bootloader.low_fuses=0xE2
atmega168bb.bootloader.high_fuses=0xD9
atmega168bb.bootloader.extended_fuses=0x07
atmega168bb.bootloader.path=arduino:atmega
atmega168bb.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
atmega168bb.bootloader.unlock_bits=0x3F
atmega168bb.bootloader.lock_bits=0x0F

atmega168bb.build.mcu=atmega168
atmega168bb.build.f_cpu=8000000L
atmega168bb.build.core=arduino:arduino 

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=32720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino 

##############################################################

usbtiny168.name=[usbtinyisp]ATmega168

usbtiny168.upload.using=usbtinyisp
usbtiny168.upload.maximum_size=14336

usbtiny168.build.mcu=atmega168
usbtiny168.build.f_cpu=8000000L
usbtiny168.build.core=arduino

##############################################################

usbtiny328.name=[usbtinyisp]ATmega328

usbtiny328.upload.using=usbtinyisp
usbtiny328.upload.maximum_size=32768

usbtiny328.build.mcu=atmega328p
usbtiny328.build.f_cpu=16000000L
usbtiny328.build.core=arduino</pre>
<p>After that, I saved the file and restarted the Arduino software. Now I had four new menu items available. Go to Tools -> Board and you will find your new options.  The two prefixed with USBTinyISP will not upload a sketch over the USB to Serial connection but rather it will require the 6 pin ISP header and will wipe out your bootloader. Of course, you can always rebootload your ATmega with your ISP programmer so that shouldn&#8217;t be an issue.  The benefit to doing it this way is that it&#8217;s a little bit faster to upload and it takes up less memory on the chip so there&#8217;s no wasted space and less of a boot time when the micro powers up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/arduino-and-the-usbtinyisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burning the Arduino Bootloader with an AVR STK500 Development Board</title>
		<link>http://www.fettesps.com/burning-the-arduino-bootloader-with-an-avr-stk500-development-board/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=burning-the-arduino-bootloader-with-an-avr-stk500-development-board</link>
		<comments>http://www.fettesps.com/burning-the-arduino-bootloader-with-an-avr-stk500-development-board/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 01:29:19 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ATmega]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[attiny]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[bootloader]]></category>
		<category><![CDATA[isp]]></category>
		<category><![CDATA[STK500]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=1345</guid>
		<description><![CDATA[I recently discovered that we had an old AVR STK500 development board lying around at work and when I had some free time I decided to play with it and see if I could use it to burn the Arduino Bootloader onto some old ATmega168 chips we had lying around. I was somewhat overwhelmed by [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered that we had an old AVR STK500 development board lying around at work and when I had some free time I decided to play with it and see if I could use it to burn the Arduino Bootloader onto some old ATmega168 chips we had lying around.  I was somewhat overwhelmed by this board as it had so many jumpers and connectors on it that I didn&#8217;t have a clue where to begin, on top of that there was no manual to be found or even a model number on it to look up &#8212; the only identifier it had on the board was the Atmel AVR logo.  I was only able to find a model number for it after digging through pages of images that came up on a Google search, once I found a picture of the same board I found my way back to <a href="http://www.efo.ru/ftp/pub/atmel/_AVR_MCUs_8bit/_Technical_Library/tools/stk/stk500/index.html">this page</a> which gave me the information I needed.  From there I was able to <a href="http://www.atmel.com/dyn/resources/prod_documents/doc1925.pdf">dig up the manual</a> as well as a few extremely outdated guides on setting it up to program an ATmega chip with a bootloader. After much frustration I finally managed to get the code to flash.</p>
<h3>You Will Need</h3>
<ul>
<li>Atmel AVR STK-500 Development Board</li>
<li>An ATMEGA or ATTiny chip</a>
<li><a href="http://www.atmel.com/products/avr/default.asp?category_id=163&#038;family_id=607&#038;source=redirect">AVR Studio 4 Software</a></li>
<li><a href="http://arduino.cc/en/Main/Software">Arduino 0022 Software</a></li>
<li><a href="http://code.google.com/p/leaflabs/source/browse/trunk/maple/hardware/arduino/bootloaders/?r=154">Arduino Bootloader HEX File</a></li>
</ul>
<p></p>
<h3>Configuring the STK-500</h3>
<p>This is the trickiest part of the setup, if you have the manual you&#8217;ll be following the directions for the ATmega8 device.  The configuration is exactly the same for the ATmega168 as well as the ATmega328.  To make sure there is no confusion, if I say <i>to the right</i> I&#8217;m referring to the side with the power and two RS232 ports, and the <i>left</i> would be the opposite side where you&#8217;ll see a row of push buttons.  Though this should go without saying, make sure you have the power disconnected from the board and you are properly grounded so that you do not cause any E.S.D. damage to your board or components.</p>
<p>First you&#8217;ll be setting some jumpers.  Place a jumper across the pins for VTARGET, AREF, RESET and XTAL1.  Next you&#8217;ll place a jumper over the two right-most pins of OSCSEL.  You&#8217;ll also be installing two jumpers on the PJUMP pins, be sure to connect the top two pins with one jumper and the bottom two with another, so the jumpers will be running left to right.  The next jumper will be one of the trickier ones, you will need a longer jumper wire and you will be running it from the right most pin of BSEL2 to the pin labeled PC2 which is located in the bank of pins labeled PORTC which is to the bottom left side of the development board.</p>
<p>Next you&#8217;ll be running two ribbon cables across the board (as seen in section 3.7.2.1 of the manual).  You&#8217;ll be connecting the PROG DATA header to the PORTB header as well as connecting the PROG CTRL header to the PORTD header.  I&#8217;ve included figure 3-17 from the manual to demonstrate this:</p>
<p><a href="http://www.fettesps.com/wp-content/uploads/2011/02/stk-500-ribbon-cables.png"><img src="http://www.fettesps.com/wp-content/uploads/2011/02/stk-500-ribbon-cables-300x250.png" alt="Arduino STK500 " title="stk-500-ribbon-cables" width="300" height="250" class="alignright size-medium wp-image-1352" /></a></p>
<p>Finish up by placing the chip into the socket labeled SCKT3200A2 which is the one outlined in Green. Pay attention to the small notch on the <i>left</i> edge of the socket, this will match up with a notch on one end of the chip.</p>
<h3>Burning the Bootloader</h3>
<div style="float:right;padding: 5px 0px 5px 15px;width:150px;border-left: 1px solid left;">
<strong>Quick Sheet:</strong></p>
<ul>
<li>Tools</li>
<li>Program AVR</li>
<li>Connect&#8230;</li>
<li>Platform: STK500</li>
<li>Port: COM1</li>
<li>Connect&#8230;</li>
<li>Tab: Main</li>
<li>Device: ATMega168 (or as desired)</li>
<li>Programming Mode and Target Settings: PP/HVSP mode</li>
<li>Tab: Program</li>
<li>Select the HEX file for your chip </li>
<li>Click Program</li>
<li>Tab: Fuses</li>
<li>Extended: 0xF8</li>
<li>High: 0xDF</li>
<li>Low: 0xFF</li>
<li>Program</li>
<li>Tab: LockBits</li>
<li>Lockbit: 0xFF</li>
<li>Program</li>
</ul>
</div>
<p>Unlike when using an ISP programmer through the Arduino software there are a few more things to do than just click &#8220;Burn Bootloader.&#8221;  For just the cliff notes follow the list on the right, or to jump to the video, otherwise keep reading. If you&#8217;ve just opened the software for the first time and it&#8217;s asking you to start a new project or open one, you&#8217;ll actually want to hit cancel.  Now in your IDE select the <b>Tools</b> menu and then <b>Program AVR</b> and then select <b>Connect&#8230;</b>  Now you&#8217;ll be presented with a screen asking about the LockBits, click back to the <b>Main</b> tab and select your Device and set the programming mode to HVSP. Before leaving this tab I recommend hitting Read Signature to to see if it reads the device fine, if it&#8217;s not hooked up right it will likely fail at this point.</p>
<p>Move on to the <b>Program</b> tab and then load your hex file.  You&#8217;re going to need the right hex file for the chip and board you&#8217;re going to be working with.  So go into your Arduino folder (e.g. C:\Program Files\Arduino\) under the <strong>Hardware\arduino\bootloaders\</strong> and start looking for one that makes the most sense.  If you don&#8217;t have the Arduino software installed yet or on this computer then another good source is <a href="http://code.google.com/p/leaflabs/source/browse/trunk/maple/hardware/arduino/bootloaders/?r=154">LeafLabs on Google Code</a>.  To be honest I&#8217;m not sure what the difference is between all the bootloaders, I just use the one in the atmega8 folder and have had no issues.  It&#8217;s also only 3kb verses 30kb which is the one whose name best maches the ATMega168 chips I&#8217;m using in this example. Once you&#8217;ve loaded the file into the AVR Studio under the Flash heading you can go ahead and hit program.  I always have the options to erase the chip and verify afterwards, so if you don&#8217;t you may want to do that manually.  If there are no errors in the bottom text move on to the Fuses tab.</p>
<p>Under the <b>Fuses</b> tab you will have to set some hex values. For the ATMega18 I was using in this example I had to set <b>Extended to 0xF8 then High to 0xDF and Low to 0xFF</b>.  This may vary depending on the chip so make sure to <a href="http://www.arduino.cc/playground/Learning/Burn168">look it up</a> before hand. Before moving on click <b>Program</b> and check the log for errors.</p>
<p>Finally, check the LockBits page.  These seem to reset to 0xFF after every program action so set them to 0xCF and hit <b>Program</b>.</p>
<p>At this point your bootloader should be burnt onto your ATMega chip and you should now be able to use it in your Arduino board. So pop it out of the STK500 and back into your Arduino board and fire up the software. From the examples menu select Blink and upload it to your device.  If the LED alternates between on and off endlessly then you are ready to rock.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/burning-the-arduino-bootloader-with-an-avr-stk500-development-board/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Burning the Arduino Bootloader with the AVR Dragon</title>
		<link>http://www.fettesps.com/burning-the-arduino-bootloader-with-the-avr-dragon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=burning-the-arduino-bootloader-with-the-avr-dragon</link>
		<comments>http://www.fettesps.com/burning-the-arduino-bootloader-with-the-avr-dragon/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 21:28:11 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ATmega]]></category>
		<category><![CDATA[atmel]]></category>
		<category><![CDATA[attiny]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[AVR Dragon]]></category>
		<category><![CDATA[bootloader]]></category>
		<category><![CDATA[USBTinyISP]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=1626</guid>
		<description><![CDATA[The AVR Dragon is a little more of an expensive route to go if you&#8217;re looking to burn Arduino Bootloaders. They can ring in around $50 per unit, though they do come in a beautiful red box with a dragon painted on it. The USBTinyISP is about $10, for comparison, and will get the job [...]]]></description>
			<content:encoded><![CDATA[<p>The AVR Dragon is a little more of an expensive route to go if you&#8217;re looking to burn Arduino Bootloaders.  They can ring in around $50 per unit, though they do come in a beautiful red box with a dragon painted on it.  The USBTinyISP is about $10, for comparison, and will get the job done just as easily &#8212; actually, it&#8217;s easier.  So if you&#8217;re going out to buy a programmer I&#8217;d recommend the USBTinyISP, however, if you&#8217;re lucky like me and have tons of gadgets like this lying around at work to play with then it&#8217;s certainly a viable option. I found this unit hiding in a dusty box on a shelf, seemingly forgotten as no one in knew what it was or why we had it, even though I already had an STK500 hooked up and ready to go as well as a USBTinyISP at home I thought I&#8217;d fire it up just for the experience.</p>
<p>The first thing you&#8217;re going to need is <a href="http://www.atmel.com/microsite/avr_studio_5/">AVR Studio</a>.  Even if you&#8217;ll be burning your bootloader through the Arduino program you&#8217;ll still need AVR Studio for the drivers.  Unfortunately I could not locate stand alone drivers and was forced to download all 600mb of AVR Studio for this purpose only, so I suggest starting that process first so you can get everything else ready while it downloads.</p>
<h3>You Will Need</h3>
<ul>
<li>Atmel AVR Dragon Board</li>
<li>An ATMEGA or ATTiny chip</li>
<li>An Arduino board (or breadboard)</li>
<li>6 pin ISP Programming Cable</li>
<li><a href="http://www.atmel.com/products/avr/default.asp?category_id=163&#038;family_id=607&#038;source=redirect">AVR Studio 4/5 Software</a></li>
<li><a href="http://code.google.com/p/leaflabs/source/browse/trunk/maple/hardware/arduino/bootloaders/?r=154">Arduino Bootloader HEX File</a></li>
</ul>
<h3>Setup the AVR Dragon</h3>
<p>In this example I&#8217;ll be using the 6 pin ISP header which I will connect to my Arduino board.  The AVR Dragon can do High Voltage Programming (HVSP) if you solder on a DIP or ZIF socket on the breadboard area to the right side.  See <a href="http://www.instructables.com/id/Help%3A-An-Absolute-Beginner-s-Guide-to-8-Bit-AVR-Pr/">this Instructables</a> Guide for instructions on how to do that.  </p>
<p>Unlike setting up the STK500 for HVSP programming the setup for the AVR Dragon in ISP mode is a breeze. The only &#8220;gotchya&#8221; is when hooking up the ISP cable make sure to align the cable so the wire with the red stripe matches the Pin 1 marker on each end.  The AVR Dragon does provide power to the destination board via the VCC headers but I found it&#8217;s easier to power the Arduino by hooking it up to another USB cable or via a walwart adapter. Once both boards have power and are connected via the ISP header you are ready to fire up AVR Studio and program the bootloader onto the chip.</p>
<h3>Programming it in AVR Studio 4</h3>
<p>AVR Studio is a free program that only requires you register with AVR in order to download it.  AVR Studio 5 is now available, and is the recommended software for this task, but this guide will stand for all who have not yet chosen to update.  </p>
<p>After loading the program you will be prompted to create a new project or load an old one.  We will do neither so hit Cancel and then on the main menu select <strong>Tools -> Program AVR -> Connect&#8230;</strong>.  Now select the <b>AVR Dragon</b> as your platform and the <b>USB Port</b> and then click <b>Connect</b> again. </p>
<p>On the next screen <b>select your device</b>, in this case the ATmega168, and select <b>ISP as your Programming Mode</b>. I always hit Read Signature to make sure everything is connected properly.  Now move on to the Program tab and under the Flash section select your HEX file.  They can be found in your Arduino installation directory, check <b>/hardware/arduino/bootloaders</b> and you will find several variations there, more can be found online.  After you have loaded the correct one hit <b>Program</b> and then when complete move to the next tab.</p>
<p>Next you&#8217;ll sit the Fuse settings.  The correct settings for the ATmega168 chip are <b>0xF8, 0xDF, 0xFF</b> but make sure to use the correct settings for the chip you are using. Click <b>Program</b> then go to the Fuse Bits tab and set it to <b>0xCF</b> and hit <b>Program</b> again.</p>
<p><object width="500" height="300"  style="margin-bottom:25px"><param name="movie" value="http://www.youtube.com/v/BNypIMxc1RM?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/BNypIMxc1RM?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="300" allowscriptaccess="always" allowfullscreen="true"></embed></object></center></p>
<p>At this point your Arduino is ready.  You can plug it in as per usual and upload a Sketch in the Arduino software.  I usually start by loading the Blink program as it is a quick and easy way to test the bootloader as the built in LED on Pin 13 will allow you to easily access if the program is running.  Make sure to upload a sketch again to make sure your lock bits were set properly, as if they are not the sketch will overwrite the bootloader and a subsequent upload will fail. </p>
<h3>Programming it in AVR Studio 5</h3>
<p>AVR Studio 5 is the new and improved way to build your AVR programs.  It runs off the Visual Studio Shell which gives .Net developers an &#8220;at home&#8221; feeling when using the software.  Beyond that I couldn&#8217;t tell you what the extra features are as I only use it for programming the bootloaders and everything else I do right in the Arduino software.  The software can still be downloaded for free after registering, and is unfortunately about 600mb to download, which is a lot for what we&#8217;ll be doing today.</p>
<p><center><object width="500" height="300" style="margin-bottom:25px"><param name="movie" value="http://www.youtube.com/v/nSSjn618_cY?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nSSjn618_cY?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="300" allowscriptaccess="always" allowfullscreen="true"></embed></object></center></p>
<p>Uploading the bootloader is pretty much the same.  Start off by going to <b>Tools</b> then <b>AVR Programming</b>.  On the next window select <b>AVR Dragon</b> as your <b>Tool</b> and <b>ATmega168</b> as your <b>Device</b>. Then <b>ISP</b> as your <b>Interface</b> then click <b>Apply</b>.  Click <b>Read</b> for both <b>Device ID</b> and <b>Target Voltage</b> to make sure everything is hooked up correctly and to initialize some settings.</p>
<p>Jump to the <b>Memories</b> tab and under Flash <b>select your HEX file</b> from the Arduino folder.  They can be found in <b>/hardware/arduino/bootloaders</b> or easily found online.  Make sure to load the proper HEX file for the chip you are working with, in this case we are using an ATmega168 chip so the file I use is <b>ATmegaBOOT_168_atmega328.hex</b> since I was too lazy to complile the ATmegaBOOT_168.c file.  Once the proper file is loaded click <b>Program</b>.</p>
<p>Now move on to the <b>Fuses</b> tab and set them to <b>0xF8, 0xDF, 0xFF</b> and then hit <b>Program</b> before moving on to the <b>Lockbits</b> tab where you will set it to <b>0xCF</b> before hitting <b>Program</b> again. Once again, verify the settings for your chip as they will vary. You may also want to tweak them to your own needs, for instance you may want to use the internal oscillator to run the chip at 8 MHz instead of the 16 MHz you get with the external crystal.  The lockbits will be configured to prevent the bootloader from being wiped each time you upload a sketch, so if you&#8217;re bootloaded chip only works once through the Arduino software&#8217;s upload method, then you likely forgot to set the lockbits or didn&#8217;t set them correctly.</p>
<h3>Testing Your Bootloaded Chip</h3>
<p>After flashing the bootloader you can disconnect the ISP header and plug the Arduino board into your USB port before loading the Arduino software.  Once it is loaded <b>open the Blink sketch </b>and then select your board and port before uploading.  The blink sketch is the best tool for testing a chip as Arduinos now come with a mini LED and a resistor already installed on Pin 13 which this sketch is configured to use.  Please note that older versions of the Arduino only had the 1k ohm resistor preinstalled so it will still need an external LED on Pin 13.  If your sketch uploads without an error you shouldn&#8217;t have any problems, but either way I suggest watching the LED for a few seconds to ensure that it alternates between on and off, if it does this then upload the sketch one more time to make sure you didn&#8217;t set the lockbits wrong.  If it works the second time then your bootloaded ATmega is ready to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/burning-the-arduino-bootloader-with-the-avr-dragon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing the Arduino IDE on Linux Mint</title>
		<link>http://www.fettesps.com/installing-the-arduino-ide-on-linux-mint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-the-arduino-ide-on-linux-mint</link>
		<comments>http://www.fettesps.com/installing-the-arduino-ide-on-linux-mint/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 12:43:38 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[atmega128]]></category>
		<category><![CDATA[ATMega328]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[diecimila]]></category>
		<category><![CDATA[duemillanove]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=761</guid>
		<description><![CDATA[The Arduino Playground does a pretty good job of directing users on how to install Arduino on Debian based distributions but there were a couple of spots where I found it was lacking, and had to go out to do my own research. The main thing it lacked was instructions on how to set up [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fettesps.com/wp-content/uploads/2009/12/arduino.png"><img src="http://www.fettesps.com/wp-content/uploads/2009/12/arduino.png" alt="arduino" title="arduino" width="128" height="128" class="aligncenter size-full wp-image-770" style="float:left; margin: 3px 10px 3px 0px" /></a></p>
<p>The Arduino Playground does a pretty good job of directing users on how to install Arduino on Debian based distributions but there were a couple of spots where I found it was lacking, and had to go out to do my own research.  The main thing it lacked was instructions on how to set up a launcher for your desktop or Gnome menu.  I will outline those at the end of this guide, but first I will give you a quick overview of the installation process from the start as I performed it on both my Linux Mint laptop and my Ubuntu 9.10 desktop.  Although this guide was written with Linux Mint users in mind, there is absolutely no reason this will not work on other Debian based distros.</p>
<p>Open up your console and run the following commands to install some necessary prerequisites.  If you know for a fact you have them installed you can skip installing them again.  You will most likely be prompted to enter Y before the installation will begin.</p>
<pre class="brush: bash; title: ; notranslate">sudo apt-get install sun-java5-jre
sudo apt-get install gcc-avr
sudo apt-get install avr-libc</pre>
<p>Now that you have the prerequisites installed you will need to <a href="http://arduino.googlecode.com/files/arduino-0017.tgz">download</a> the newest version of Arduino.  You can save it to your desktop for now.  After it has finished downloading open up the folder and extract it to your desired location (such as your home directory) or you can do it in your console as well:</p>
<pre class="brush: bash; title: ; notranslate">tar xvzf ~/Desktop/arduino-0017.tgz ~/Arduino</pre>
<p>At this point it is safe to delete the tarball on your desktop.  </p>
<p>At this point Arduino is installed and ready to use. This is also where the Arduino Playground leaves you hanging, no one wants to open up their console every time to launch a program or browse to it with their file explorer.  I initially tried creating an installer just as I normally would, by pointing it to ~/Arduino/arduino) only to find that the program did not launch when I clicked it.  So I then created a bash script which called the same file and made sure it was executable.  Still nothing!  So that&#8217;s when I realized that I had to do things a bit differently.  Nothing too fancy, just a slightly different way of approaching it.</p>
<p>First create an empty bash file and make it executable.  </p>
<pre class="brush: bash; title: ; notranslate">touch ~/Arduino/runArduino.sh
chmod a+x ~/Arduino/runArduino.sh</pre>
<p>Then open it in your favourite text editor (e.g. emacs or pico), and add the following contents to your bash script:</p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash
cd ~/Applications/Arduino &amp;&amp; ./arduino</pre>
<p>Save the file and close your terminal.  Right click the Gnome menu and select <strong>Add to Panel</strong>.  Select <strong>Custom Application Launcher</strong> and hit <strong>Add</strong>.  Enter <strong>Arduino</strong> for the name, and in the path put <strong>/home/username/Arduino/runArduino.sh</strong>. You can also select an icon for the launcher, which is another place Linux users were left out in the cold as the tarball does not contain an SVG file. Fortunately, I did manage to dig up a <a href="http://www.fettesps.com/wp-content/uploads/2009/12/arduino.png">PNG version</a> to use. Save this icon to your install directory and select it by clicking the &#8220;spring&#8221; icon and navigating to your install directory.  From there click close to save the settings and add the launcher to your panel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/installing-the-arduino-ide-on-linux-mint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time Keeping with the Arduino and DS1302</title>
		<link>http://www.fettesps.com/time-keeping-with-the-arduino-and-ds1302/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=time-keeping-with-the-arduino-and-ds1302</link>
		<comments>http://www.fettesps.com/time-keeping-with-the-arduino-and-ds1302/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 12:45:06 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[chronobox]]></category>
		<category><![CDATA[ds1302]]></category>
		<category><![CDATA[lockbox]]></category>
		<category><![CDATA[maxim ic]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=1120</guid>
		<description><![CDATA[The Chronobox (Part 3) After ordering a few more supplies on the weekend my shipment arrived on Wednesday, the main thing I was waiting on was a time keeping chip and I had selected the DS1302 from Maxim IC to do that job. Aside from that I got a crystal for the clock, a few [...]]]></description>
			<content:encoded><![CDATA[<h3>The Chronobox (Part 3)</h3>
<p>After ordering a few more supplies on the weekend my shipment arrived on Wednesday, the main thing I was waiting on was a time keeping chip and I had selected the DS1302 from Maxim IC to do that job.  Aside from that I got a crystal for the clock, a few mini servos, some stackable headers (to make my proto shield and motor shield stackable), push buttons, a piezo speaker and some other various headers and connectors.<br />
<a href="http://www.fettesps.com/wp-content/uploads/2010/12/ds1302_bb-e1292204405976.png"><img src="http://www.fettesps.com/wp-content/uploads/2010/12/ds1302_bb-e1292204405976.png" alt="Arduino + ds1302 Circuit (Fritzing)" title="Arduino + ds1302 Circuit (Fritzing)" width="289" height="228" class="alignright size-full wp-image-1109" style="margin: 25px 0px 0px 10px;" /></a><a href="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0607.jpg"><img src="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0607-300x225.jpg" alt="DS1302 on Protoshield" title="DS1302 on Protoshield" width="300" height="225" class="alignright size-medium wp-image-1104"  style="margin: 25px 0px 0px 10px;" /></a><br />
I was very eager to try out the clock chip and rushes straight home and went to work.  I pulled a 3V battery out of an old motherboard and popped it into a 3V battery holder I had bought a while back (note: the 3V battery and holder is represented by a piezo speaker in this diagram as there was no part for a 3V battery).  I popped that into one side of the mini breadboard on the Protoshield and installed the DS1302 on the other side.  Wiring the circuit was a breeze and I didn&#8217;t even have to pull up the data sheet.  The chip came attached to a business card sized information sheet that had the pin outs on the back.  Thank you <a href="http://www.hvwtech.com/">HVW Technologies</a>!  I&#8217;ll be using the pin labels from that card and providing the alternative marker from the Fritzing diagrams in brackets.</p>
<p>The DS1302 has two pins for power input and which ever is capable of providing more power will take over and power the clock and crystal.  <a href="http://www.fettesps.com/wp-content/uploads/2010/12/ds1302_schematic-e1292205962573.png"><img src="http://www.fettesps.com/wp-content/uploads/2010/12/ds1302_schematic-e1292205962573-150x150.png" alt="DS1302 Schematic (Fritzing)" title="DS1302 Schematic (Fritzing)" width="150" height="150" class="alignleft size-thumbnail wp-image-1129" style="margin: 5px 10px 5px 0px;" /></a> So I hooked the Vcc1 (V+) to the 3.3v pin and the Vcc2 (Vbat) to the 3v battery. The idea being that if I unplug the device (USB or power adapter) the 3.3v pin will stop providing power to circuit and the battery will seamlessly take over so no time is lost.  When the circuit regains power the DS1302 has a built in trickle charge circuit that will charge up the 3v battery for you.  The X1 and X2 pins are bridge with a crystal, the ground to the ground rail of course and the remaining three pins are SCLK, I/O and RST (CE) are run to pins 7, 6 and 5, respectively.  </p>
<p>The code was very simple and was all build on the <a href="http://quadpoint.org/projects/arduino-ds1302">RTC Library</a> which I found on the Arduino site.  The code is very rough at this point and just prints the time every second over serial, during the range of 9pm to midnight it will print Unlocked and all other hours will print Locked.  Eventually the code will be altered to query the locked/unlocked status on button press and if it falls within the time range the servo will unlock the box.</p>
<pre class="brush: plain; title: ; notranslate">//  @author: Brad Fettes &lt;http://www.fettesps.com&gt;
//  @thanks: Matt Sparks &lt;http://quadpoint.org/projects/arduino-ds1302&gt;
//  @date: December 9, 2010
//  @purpose: Check the ds1302 to see if the chronobox should be locked or unlocked

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;DS1302.h&gt;

// Set the appropriate digital I/O pin connections
uint8_t CE_PIN   = 5;	// RST
uint8_t IO_PIN   = 6;
uint8_t SCLK_PIN = 7;

// Create a DS1302 object
DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);

// Create buffers
char buf[50];
char day[10];

// Thanks to the Arduino library...
void check_alarms() {
  // Get the current time and date from the chip
  Time t = rtc.time();

  // Name the day of the week
  memset(day, 0, sizeof(day));  // clear day buffer 

  // Check the hour
  snprintf(
             buf, sizeof(buf), &quot;%02d:%02d:%02d&quot;,
             t.hr, t.min, t.sec
          );
  Serial.print(buf);
  Serial.print(&quot; - &quot;);
  switch (t.hr) {
    case 21: // After 9 pm
      Serial.println(&quot;UNLOCKED&quot;);
      break;

    case 22: // After 10 pm
      Serial.println(&quot;UNLOCKED&quot;);
      break;

    case 23: // After 11 pm
      Serial.println(&quot;UNLOCKED&quot;);
      break;

    default:
      Serial.println(&quot;LOCKED&quot;);
  }
  Serial.println();
}

void set_time() {
  /*
     Initialize a new chip by turning off write protection and clearing the
     clock halt flag. These methods needn't always be called. See the DS1302
     datasheet for details.
  */
  rtc.write_protect(false);
  rtc.halt(false);

  // Make a new time object to set the date and time
  Time t(2010, 12, 9, 11, 11, 0, 4);  // e.g. Thursday, Dec 9, 2010 at 11:11:00

  // Set the time and date on the chip
  rtc.time(t);
}

void setup() {
  // Ensure that we have a few seconds to upload code
  delay(2500);

  // then start serial communication
  Serial.begin(9600); 

  // Uncomment to set the time to the one defined above
  // make sure to upload it again uncommented or it will reset
  // the date each time gets powered up
  //set_time();
}

/* Loop and print the time every second */
void loop() {
  check_alarms(); // Lock or Unlock
  delay(1000); // wait one sec
}
</pre>
<p>The next step here is to combine this sketch with the one from <a href="controlling-a-lock-with-an-arduino-and-a-servo">Part 2</a> where I controlled a locking mechanism with a servo.  I will also need a way to provide feedback to the user by a piezo or LCD panel.  Stay tuned for Part 4 which will be posted just after the new year.  Happy holidays!</p>
<p><b>Download the Project Files:</b><br />
<a href="http://www.fettesps.com/files/lockbox-ds1302.fz">Frizing Project</a><br />
<a href="http://www.fettesps.com/files/lockbox-ds1302.pde">Arduino Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/time-keeping-with-the-arduino-and-ds1302/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Controlling a Lock with an Arduino and a Servo</title>
		<link>http://www.fettesps.com/controlling-a-lock-with-an-arduino-and-a-servo/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=controlling-a-lock-with-an-arduino-and-a-servo</link>
		<comments>http://www.fettesps.com/controlling-a-lock-with-an-arduino-and-a-servo/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 12:48:23 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fritzing]]></category>
		<category><![CDATA[lockbox]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=1101</guid>
		<description><![CDATA[The Chronobox &#8211; Part 2 The other day I wrote about a project I was building that was a time based lockbox which I have now dubbed the &#8220;Chronobox.&#8221; Much like the Reverse Geocache this lockbox can only be opened from the inside and that will only happen if a certain set of parameters are [...]]]></description>
			<content:encoded><![CDATA[<h3>The Chronobox &#8211; Part 2</h3>
<p>The other day <a href="http://www.fettesps.com/arduino-prototyping-with-fritzing/">I wrote about a project</a> I was building that was a time based lockbox which I have now dubbed the &#8220;Chronobox.&#8221;  Much like the Reverse Geocache this lockbox can only be opened from the inside and that will only happen if a certain set of parameters are met.  In this case, that parameter is time.</p>
<p>Today, rather than focusing on Fritzing, I&#8217;ll be starting to cover some builds I&#8217;ve done on the protoshield to get familiar with each of the components needed for this project as well as to try out a few different locking mechanisms I&#8217;ve had on my mind.  <a href="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0592.jpg"><img class="alignleft size-medium wp-image-1105" title="Arduino Pushbutton Servo" src="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0592-300x225.jpg" alt="" width="300" height="225" style="margin: 5px 10px 0px 0px;" /></a>The first will be a simple circuit used to control a servo which will open a latch. My setup is just a standard blue Arduino Duemilanove and a <a href="http://www.adafruit.com/index.php?main_page=product_info&amp;cPath=17_21&amp;products_id=51">Proto Shield</a> from Adafruit with a mini breadboard fastened on top.  I also have a <a href="http://www.adafruit.com/index.php?main_page=product_info&amp;cPath=17_21&amp;products_id=81">motor shield</a> from Adafruit as well but I need to remove the current headers and replace them with stackable headers before its of any use to me, why all shields font come with these by default is beyond me.  My final configuration will likely be built out on a Hardcopy (which is apparently now known as the <a href="http://www.spikenzielabs.com/SpikenzieLabs/Prototino.html">Protino</a>).</p>
<p>Wiring the circuit was quite simple, I took 3 break away header pins and slit the center divider down to the middle and pushed it into the header from the servo which then allowed me to plug the header into the bottom right of the mini breadboard.<a href="http://www.fettesps.com/wp-content/uploads/2010/12/Servo-Pushbutton-Schematic-e1292210097776.png"><img class="alignright size-thumbnail wp-image-1153" style="background: white; padding: 5px 5px 5px 5px; margin-left: 15px; margin-top: 5px;" title="Arduino Servo/Pushbutton - Schematic" src="http://www.fettesps.com/wp-content/uploads/2010/12/Servo-Pushbutton-Schematic-e1292210097776-150x150.png" alt="Arduino Servo/Pushbutton - Schematic" width="150" height="150" /></a>The black wire was ran to the ground rail and the red wire run to the 5v rail (if you&#8217;re not using a proto shield you can just run them directly to the ground and 5v pins on the arduino).  The yellow control wire was run to on of the Digital PWM pins (Pin 9 in my case).  The switch was wired by running a ground wire with a 1k Ohm resistor bridging the gap and a wire run to the 5v rail.  Another line is then run from Digital pin 10 to a position between the 1k Ohm resistor and the push button.  When the button is idle the current will run from the ground, through the resistor into the input pin giving you a reading of low and when you press the button 5v is sent through the circuit into a the digital pin which will cause it to read high.  The resistor is there to stop the 5v current from running directly to the ground instead of the digital pin.</p>
<p><a href="http://www.fettesps.com/wp-content/uploads/2010/12/Servo-Pushbutton021.png"><img class="aligncenter size-medium wp-image-1152" style="background: white; padding: 5px;" title="Servo-Pushbutton 02 (Fritzing)" src="http://www.fettesps.com/wp-content/uploads/2010/12/Servo-Pushbutton021-e1292209747403-300x157.png" alt="Servo-Pushbutton 02 (Fritzing)" width="300" height="157" /></a></p>
<p>The code is pretty straight forward and is a combination of the Sweep and Button examples that came with the platform.  The pushbutton will be set to pin 10 for input and the LED pin will be pin 9 set for output and the servo will be attached to pin 5.  If you aren&#8217;t using the Protoshield you can skip the LED or just use the built in LED and 1k Ohm resistor on pin 13 instead.  When the button is pressed the LED pin will be set high and using the servo library I&#8217;ll be rotating between two positions which through experimentation I&#8217;ve determine to be just the right arc to lock or unlock the box.</p>
<pre class="brush: plain; title: ; notranslate">// @author : Brad Fettes &lt;http://www.fettesps.com&gt;
// @date   : Dec 04, 2010
// @thanks : Sweep by BARRAGAN &lt;http://barraganstudio.com&gt;
//		   : Button by Tom Igoe &lt;http://www.arduino.cc/en/Tutorial/Button&gt;

#include &lt;Servo.h&gt;

int inputPin = 10;      // Push button input pin
int btnVal = 0;         // Current value of pushbutton

int ledPin = 5;			// Pin for Green LED built into proto shield

int outputPin = 9;      // Servo pin
int servo_pos = 0;      // Current servo position
int servo_pos_a = 20;   // Position destination a
int servo_pos_b = 65;   // Position destination b
int servo_state = 0;    // 0 = position a, 1 = position b

Servo mrservo;  // create servo object to control the servo

void setup() {
  pinMode(inputPin, INPUT); // Push Button
  pinMode(ledPin, OUTPUT); // LED

  mrservo.attach(outputPin);  // attaches the servo on pin 9 to the servo object

  // Debug messages via serial monitor
  Serial.begin(9600);
  Serial.println(&quot;Starting...&quot;);
}

void loop() {
  // Check to see if button is LOW or HIGH (5v)
  btnVal = digitalRead(inputPin);

  if(btnVal == LOW) {
    Serial.println(&quot;Button: LOW&quot;);
    digitalWrite(ledPin, LOW);

    if(servo_state) {
      Serial.println(&quot;Position: a&quot;);
    } else {
      Serial.println(&quot;Position: b&quot;);
    }
  }

  if(btnVal == HIGH) {
    Serial.println(&quot;Button: HIGH&quot;);
    digitalWrite(ledPin, HIGH);

    if(servo_state) {
      Serial.println(&quot;Position: a&quot;);
    } else {
      Serial.println(&quot;Position: b&quot;);
    }

    // Move from position a to position b
    if(servo_state == 0) {
      // I don't know how to concatenate
      Serial.print(servo_pos_a); Serial.print(&quot; to &quot;); Serial.println(servo_pos_b);

      for(servo_pos = servo_pos_a; servo_pos &lt; servo_pos_b; servo_pos += 1) {
        mrservo.write(servo_pos);
        delay(15);                       // waits 15ms for the servo to reach the position
      }
      servo_state = 1;

    } else {  // Move from position b to position a

      Serial.print(servo_pos_b); Serial.print(&quot; to &quot;); Serial.println(servo_pos_a);

      for(servo_pos = servo_pos_b; servo_pos &gt;= servo_pos_a ; servo_pos -= 1) {
        mrservo.write(servo_pos);
        delay(15);
      }
      servo_state = 0;
    }
  }

  // Separate each cycle's output
  Serial.println(); Serial.println();
  delay(250);
}
</pre>
<p>Here&#8217;s a video out the servo with a meccano arm attached rotating between positions A and B:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/7ze09GUIRpM?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7ze09GUIRpM?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><a href="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0598.jpg"><img class="alignright size-medium wp-image-1107" style="margin: 15px 0px 5px 10px;" title="Arduino Lockbox Prototype" src="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0598-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://www.fettesps.com/wp-content/uploads/2010/12/IMG_0595.jpg">I sculpted a prototype out of a small box</a> I had lying around.  It isn&#8217;t perfectly to scale as it&#8217;s not nearly as tall as my lockbox but the base dimensions are about the same.  After building a few latches out of cardboard and tacks I found a design I liked and made a more permanent latch with some mecanno like materials I had. I affixed it to the front of the box and hot glued a servo in place and wrote some code to try out the lock and see how it works.</p>
<p>I ran into a bit of an issue where when it&#8217;s in its reseting state the weight of the latch pulls down on the pivot point causing the longer shaft to lift up over the center line of the pivot point so when it pushes forward again the latch spins the wrong way.  In order to prevent this from happen I took another random piece of meccano and glued it under the latch so it had a resting post.  After a few tests runs I was satisfied with this solution.</p>
<p>I&#8217;m still not sure I&#8217;m happy with this latching method, so I think I&#8217;ll be testing out some other builds before I choose which method I&#8217;ll use in my final build.  One idea that was suggested to me, which made me chuckle because it was so simple I couldn&#8217;t believe I hadn&#8217;t thought of it, is to just attach the latch itself to a servo and mount it higher up, that way you don&#8217;t have joints which could fault on you and leave you with a lockbox jammed shut.  I&#8217;ve been considering this idea as well as doubling up and having two servos locking and unlocking the box, as I don&#8217;t want someone to be able to pull it open with brute force.  On top of that I&#8217;m resisting the urge to take the Dremel to the back casing on the key lock which is built into the cash box so I can see what&#8217;s going on in there, and possibly control it with a servo instead of a key.  The built in lock is very solid and you&#8217;d never be able to pull it open with brute force.</p>
<p><strong>Download the Project Files:</strong></p>
<p><a href="http://www.fettesps.com/files/lockbox-btn+servo.fz">Frizing Project</a><br />
<a href="http://www.fettesps.com/files/lockbox-btn+servo.pde">Arduino Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/controlling-a-lock-with-an-arduino-and-a-servo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World on the Arduino</title>
		<link>http://www.fettesps.com/hello-world-on-the-arduino/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hello-world-on-the-arduino</link>
		<comments>http://www.fettesps.com/hello-world-on-the-arduino/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 19:36:06 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ATmega]]></category>
		<category><![CDATA[ftdi]]></category>
		<category><![CDATA[Hello World]]></category>
		<category><![CDATA[Serial]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=556</guid>
		<description><![CDATA[Love it or hate it, every programmer typically wets their feet by writing a &#8220;hello world&#8221; program in their new programming environment. Since unlike with the type of code I&#8217;m used to writing the Arduino board doesn&#8217;t come with a CRT or LCD screen to output this text, we have to find a more creative [...]]]></description>
			<content:encoded><![CDATA[<p>Love it or hate it, every programmer typically wets their feet by writing a &#8220;hello world&#8221; program in their new programming environment.  Since unlike with the type of code I&#8217;m used to writing the Arduino board doesn&#8217;t come with a CRT or LCD screen to output this text, we have to find a more creative way to do this.  There are many options, such as LEDs, peizo buzzers, small LCD pannels and speakers that could be used to output a message.  The Hello World sketchbook found in the examples outputs the text &#8220;Hello World&#8221; to the serial port monitor, we will be building upon this example and using an LED to output this same message. The Duemilanove comes with an LED build into the board and is attached to PIN 13.  This is very convenient as the experimentation kit did not come with even a single LED to play with.  I did, however, order a couple different types of LEDs with my order as I knew I wanted them to play around with.  For this example we will use the onboard LED as it requires no wiring and gives you a good way to get comfortable with uploading your program to the board and the basic structure of the code.</p>
<p>Start off by loading the Arduino development environment and on the main menu select File-&gt;Examples-&gt;Stubs-&gt;HelloWorld.  The following project will be loaded into your sketchbook:</p>
<pre class="brush: cpp; title: ; notranslate">void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(&quot;Hello World!&quot;);
}
</pre>
<p>This is the basic structure of all Ardino programs.  These two functions are the heart of every program you will write, so it doesn&#8217;t hurt to take a moment and discuss them.  Both functions must be declared outside of the scope of all other functions.  They are declared as void so they are not expected to return any value and they do not require any parameters.  The setup funciton is called once when your board first powers up, and is used to initialize any devices or pins that are going to be used in your program.  After the setup function executes the loop function begins to run, and it will continue to run endlessly until you power off your board.  When first beginning to work with microcontrollers it takes a bit of time to wrap your head around the way the execute code, in an infinite loop, as this is somewhat different from the way any programs would run on your desktop or server computer.</p>
<p>In the setup function you will see that the board is configured for serial communications with the command <em>Serial.begin(9600);</em>.  It is set to communicate at 9600 baud and it is important to note that even though we are using an emulated serial port over USB that pins 0 (Rx) and 1 (Tx) are wired to the FTDI USB-to-TTL Serial chip so they will be unavailable whenever you are performing serial communication over USB.</p>
<p>In the loop function <em>Serial.println(&#8220;Hello World!&#8221;);</em> is used to echo Hello World back to the computer over the serial connection.  In order to see this message you will have to hit the Serial Monitor button on your toolbar.  The serial monitor provides us with one of our only ways to debug our code, by echoing debug information back to our computer.  And of course the serial communication ports on the Arduino can be used for more advanced purposes.</p>
<p>So how can we make this example a little more interesting?  How about programming the onboard LED to flash Hello World in morse code?  If you have a pack of LEDs and transistors you could also set up an array of LEDs to spell it out in binary.  Since the Experiementation Kit did not include these, I will stick with using the LED connected to pin 13.  The first step was to find a reference for morse code, a quick trip to <a href="http://en.wikipedia.org/wiki/Morse_code">Wikipedia</a> gave me everything I needed. After that you will need a quick intro to working with LEDs, the best way to do that is to select File-&gt;Examples-&gt;Digital-&gt;Blink from the menu and take a look at the code there.</p>
<pre class="brush: cpp; title: ; notranslate">/*
Blink

Turns on an LED on for one second, then off for one second,
repeatedly.

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the
board connected to pin 13, so you don't need any extra components
for this example.

Created 1 June 2005
By David Cuartielles

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board
*/

int ledPin =  13;    // LED connected to digital pin 13

void setup()  {
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power
void loop() {
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(1000);                  // wait for a second
}</pre>
<p>The command <em>pinMode</em> in the setup function is used to tell the micro that pin 13 is going to be used for output.  In your main loop you are simply telling it to turn on (HIGH) and off (LOW) by passing the pin number and mode to the <em>digitalWrite</em> command.  You could also use the <em>analogWrite</em> command but since pin 13 does not support PWM you would only be able to set it to on or off, rather than adjust the brightness.  Pins 3, 5, 6, 9, 10, and 11 on the Duemilanove support PWM and if you need to create a pulsing effect with your LEDs you will have to to hook up an LED and 1K Ohm resistor to one of those pins.  At this point, stick with pin 13, and hit the upload button again and watch what happens.  From there I would suggest tweaking the delays to create different blinking patterns if you feel you need to get a bit more comfortable with LEDs before moving on.</p>
<p>When you&#8217;re ready, we&#8217;ll begin splicing these two examples together and creating our morse code flasher.  If you have an extra LED sitting around feel free to plug the long leg into pin 13 and the short leg into the ground (GND) beside it.  Since pin 13 has a resistor built in we to not need to do anything more than that.  At the top of your project declare some new variables.  We&#8217;re going to do this before any of the core functions as they need to be accissible by all of them.</p>
<pre class="brush: cpp; title: ; notranslate">int delayDot = 200;
int delayDash = 500;
int delayLetter = 250;
int delayWord = 500;</pre>
<p>These variables store the delay time in milliseconds for the two different &#8220;characters&#8221; and the spacing between them.  These can be tweaked to your liking, I personally don&#8217;t know Morse Code so I&#8217;m not sure how acturate the timings are.</p>
<p>Next you will be adding some code to the setup() and loop() functions.  </p>
<pre class="brush: cpp; title: ; notranslate">void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  print_morse_code(&quot;h&quot;);
  print_morse_code(&quot;e&quot;);
  print_morse_code(&quot;l&quot;);
  print_morse_code(&quot;l&quot;);
  print_morse_code(&quot;o&quot;);
  print_space(1);
  print_morse_code(&quot;w&quot;);
  print_morse_code(&quot;o&quot;);
  print_morse_code(&quot;r&quot;);
  print_morse_code(&quot;l&quot;);
  print_morse_code(&quot;d&quot;);
  delay(1000);
}</pre>
<p>The setup() function tells the board it will be outputting over the FTDI bus and prepares Pin 13 for output.  The loop calls a function called print_morse_code() which is a very basic character map for the differenet pulses, it simply masses the character passed in with its list of options and outputs the proper sequence for each. At the end of the main loop is a 1 second delay before it starts over from the beginning.</p>
<p>Before we look at the print_morse_code() function lets look at the functions that create the characters.</p>
<pre class="brush: cpp; title: ; notranslate">
void print_dot() {
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(delayDot);                  // wait for a second
}

void print_dash() {
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(delayDot);                  // wait for a second
}

// Turn off LED
// 0 = Letter
// 1 = Word
void print_space(byte len) {
  digitalWrite(ledPin, LOW); // set LED off
  if(len) {
      delay(delayWord);
  } else {
      delay(delayLetter);
  }
}</pre>
<p>They&#8217;re quite simple functions.  The LED is set to HIGH and the module waits 250ms for a dot and 500ms for a dash before it moves on to the next digit.  The next function, print_space(), is a bit more intricate.  It requires a parameter to be passed in to determine which delay is going to be used after turning the LED off.  We want a 200ms space between each letter and a 500ms space between each word.</p>
<p>The last function we need is print_more_code() which ties it all together.  It&#8217;s not pretty, but it works.</p>
<pre class="brush: cpp; title: ; notranslate">// Convert letters to to morse code via LED and Serial echos
void print_morse_code(char* letter) {
  // Hello
  // ****  *  *-**  *-**  ---

  // World
  // *--  ---  *-*  *-**  -**

  if(letter==&quot;h&quot;) {
      Serial.println(&quot;****&quot;);
      print_dot();
      print_dot();
      print_dot();
      print_dot(); 

  } else if (letter==&quot;e&quot;) {
      Serial.println(&quot;*&quot;);
      print_dot();

  } else if (letter==&quot;l&quot;) {
      Serial.println(&quot;*-**&quot;);
      print_dot();
      print_dash();
      print_dash();
      print_dash();

  } else if (letter==&quot;o&quot;) {
      Serial.println(&quot;---&quot;);
      print_dash();
      print_dash();
      print_dash();

  } else if (letter==&quot;w&quot;) {
      Serial.println(&quot;*--&quot;);
      print_dot();
      print_dash();
      print_dash();

  } else if (letter==&quot;r&quot;) {
      Serial.println(&quot;*-*&quot;);
      print_dot();
      print_dash();
      print_dot();

  } else if (letter==&quot;d&quot;) {
      Serial.println(&quot;-**&quot;);
      print_dash();
      print_dot();
      print_dot();
  }

  print_space(0);
}</pre>
<p>A character is passed in and matched to a sequence of calls to print_dot() and print_dash() to create the desired letter.  At the end a letter space is added for padding making it easier to understand the transmission.  And just to help out with decrypting the message I output the currect character to the serial port so you can follow along on your computer.</p>
<p>The code for this entire project is available on <a href="http://code.google.com/p/arduino-morse-code-hello-world/">Google Code</a> for reference.  I encourage anyone to build off of it or optimize it.  Just keep in mind I&#8217;m not a C programmer <img src='http://www.fettesps.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/hello-world-on-the-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Experimentation Kit Review</title>
		<link>http://www.fettesps.com/arduino-experimentation-kit-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=arduino-experimentation-kit-review</link>
		<comments>http://www.fettesps.com/arduino-experimentation-kit-review/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 00:15:13 +0000</pubDate>
		<dc:creator>FettesPS</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ATMega328]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[ftdi]]></category>
		<category><![CDATA[microcontroller]]></category>

		<guid isPermaLink="false">http://www.fettesps.com/?p=535</guid>
		<description><![CDATA[I recently got my hands on the Arduino Experimentation Kit from RobotShop.ca and have been tinkering away all weekend. There are many Arduino starting kits available out there and it&#8217;s somewhat overwhelming for someone like myself with very little experience in the field of microcontrollers to decide which to order. In the end I chose [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got my hands on the Arduino Experimentation Kit from <a href="http://www.robotshop.ca">RobotShop.ca</a> and have been tinkering away all weekend. There are many Arduino starting kits available out there and it&#8217;s somewhat overwhelming for someone like myself with very little experience in the field of microcontrollers to decide which to order.  In the end I chose to go with RobotShop&#8217;s kit because they were local to me (Canada) and when it came time to expand upon my kit they had every sensor and part I could ever imagine needing.</p>
<h3>Comparison</h3>
<p>They had two packages available, the <a href="http://www.robotshop.ca/arduino-experimentation-kit.html">Arduino Experiementation Kit</a> for $85 CDN and the <a href="http://www.robotshop.ca/robotshop-arduino-basic-kit.html">Arduino Basic Kit</a> for $55 CDN.  Both kits come with the Arduino Duemilanove board, a mini solderless breadboard, a USB cable for power and programming the micro and a jumper wire kit.  The basic kit also comes with a power supply, which for some reason the more expensive kit lacks.  The experimentation kit adds a servo, rotation sensor, infrared sensor and some break away headers.  Since I wanted to be able to actually make something with my micro and not need to pick up tons of extra parts from elsewhere I went with the experimentation kit.</p>
<h3>Analysis</h3>
<h4>Arduino Duemilanove USB Microcontroller Module</h4>
<p>Comes fully assembled and the ATMega328 is pre-loaded with the Arduino bootoader. I was immediately disappointed by the fact that my row of 6 analog connectors was soldered in crooked.  Rather than be at a 90 degree angle with the board it is sitting at about 75 degrees.  The solder joint is solid enough that I can&#8217;t just bend it back in to position, and I&#8217;m confident that in its current state I will not be able to snap on any shields unless I heat up the solder joint and reposition it.  The board is usuable, however I don&#8217;t feel it should have made it past quality control.</p>
<h4>Sharp GP2D12 IR Range Sensor</h4>
<p>Definitely a fun sensor to play with.  One of my first designs was a motion sensor that lights up an LED when you put your hand in front of the sensor.  From there I improved it by changing the brightness of the LED based on the distance from the sensor.  A quick Google search for this sensor and you will find the datasheet as well as plenty of code examples as it seems to be a very common choice.</p>
<h4>Phidgets Rotation Sensor</h4>
<p><img src="http://www.fettesps.com/wp-content/uploads/2009/08/arduino-experimentation-kit-B-150x150.jpg" alt="arduino-experimentation-kit-B" title="arduino-experimentation-kit-B" width="150" height="150" class="size-medium wp-image-563" style="float:right; padding: 0px 0px 10px 15px;" /></p>
<p>All my research on this device has told me to use it with the Phidgets Interface Kit.  So it was like they had a bunch of these lying around and just tossed them in to get rid of them. I did manage to find a Product Manual for it thankfully and was able to determine that it used the analog pins and returned a value between 0 and 1000 based on the position of the knob.</p>
<h4>Hitec HS-422 Servo Motor</h4>
<p>Haven&#8217;t played with this part much yet, sometime this week I will hook it up and the rotation sensor and see if I can get the two working together.  Other than that, it looks well made and its by a reputable manufacturor.</p>
<h4>Mini Self Adheasive Solderless Breadboard</h4>
<p>I&#8217;d be lost without this component.  I am the worst at soldering and I certainly don&#8217;t want to make any of my circuits permanent at this point.  The breadboard allows me to prototype out all my little ideas and make mistakes along the way. It does seem weird to be using it without the Proto Shield though, as it is forced to sit to the side rather than on top of the module.</p>
<h4>Pre-formed Jumper Wire Kit</h4>
<p>Wasn&#8217;t really sure what these were going to be until I got them.  Now that I know what they are I love them.  No need to measure, cut or strip wires &#8212; just find the right jumper and plug it in.  It&#8217;s really simple.</p>
<h4>Break Away Headers</h4>
<p>Haven&#8217;t found these to be very useful.  So far I&#8217;ve only broken off 3 and it was to use to connect the IR sensor to the breadboard. Problem is the plastic strip that divides the two ends isn&#8217;t centered.  So either I get a good connection on the breadboard or a good connection on the IR sensor, not both.  As a result I&#8217;ve knocked the sensor out many times while playing with it.</p>
<h3>Getting Set Up</h3>
<p>Since right now my main OS is Windows 7 I will be doing all of my development under it.  The development environment is written in Java so if you are more at home in OSX or Linux then you can just as easily do your development there.  The software package can be download directly from <a href="http://arduino.cc/en/Main/Software">Arduino.cc</a> where you can also look up code examples and anything else you need to get going.</p>
<p>The Arduino works be emulating a serial port over USB and uses the FTDI drivers which come packaged with the development software.  Unfortunately this bundled set of drivers is out dated and would not work with my computer.  I had to try several sets of drivers before I found ones that worked with Windows 7 x64.  The most up-to-date drivers can be obtained from <a href="http://www.ftdichip.com/Drivers/VCP.htm">FTDI&#8217;s website</a>. One thing to note is that when installing virtual com port drivers you will notice that after the first device is installed you will again be prompted to install another set of drivers.  One is the USB Serial Converter and the second is the USB Serial Port.  I personally didn&#8217;t like the port that was auto assigned to my Arduino so I went into device manager and disabled what was already on COM1 (which I was not using) and opened up the properties of the USB Serial Port, clicked the Port Settings tab, then Advanced.  Here I selected COM1 and hit ok, after accepting the warning that another device was using that port I was back to Device Manager. From there I right clicked Communications Port (COM1) and selected disable.  Even if you don&#8217;t want to change the port it is running under you would still be wise to go into Device Manager and find out for sure which port it is using as you will need to know this when it comes time to upload your program to your Arduino.</p>
<p>After installing both the FTDI drivers and the Arduino development environment all that&#8217;s left is a small amount of configuration.  Start up Arduino 0017 and select Tools -&gt; Board -&gt; Arduino Duemilanove or Nano w/ ATmega328.  Then again under the Toosl menu select Serial Port and the port you are using (in my case COM1).  Your software is now configured, at this point I would recommend reading some  of the examples found under the file menu.</p>
<h3>Conclusion</h3>
<p>Overall I&#8217;m happy with the kit, I&#8217;ve been itching to get my hands on a Arduino board for some time now and they had it in my hands just two days after ordering the kit online.  On top of that it came with two sensors and one device to output through (not including the onboard LED).  The devices it came with are certainly not the ones I would have picked if I was building a kit of my own they are definitely handy and I will have lots of fun finding a use for them.</p>
<p>I would have liked to have seen three things included in this kit, as they were strangely absent.  The first is the power supply.  It strikes me as very odd that it would be offered in the cheaper package but not the high end package.  The second is a pack of LEDs, they&#8217;re cheap enough that they should have thrown in at least two or three different colours to play with.  To go with those you would have needed a pack of resistors, they are also quite cheap and are essential for lighting LEDs without blowing them.  I picked up a pack of both at Radio Shack as I felt lost without them. There are other things, such as a proto shield, that I would have loved to have in my starter kit but those are a fair bit more expensive and would have certainly raised the price of the kit. My biggest gripe would definitely be the crooked row of analog Pins.  I was extremely disappointed to discover this.</p>
<p>The Arduino Experimentation Kit offers a beginner developer enough to get started, and it is packaged at a reasonable price. If you know specifically what you&#8217;d like to start building you&#8217;d be better off to build your own kit out of parts that are easily available on their website.  I will definitely be going back to RobotShop.ca for some more supplies as their prices are reasonable and they are conveniently quite close to me.  However if you live in the states, or you don&#8217;t have tons of random electrical components laying around your apartment waiting for you to build something out of them like I do, then you&#8217;d probably be wiser to order <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=MSAPK2">The Advanced Arduino Starter Kit</a> from MakerShed which would come with almost everything you could possibly need in your early stages of Arduino proto-typing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fettesps.com/arduino-experimentation-kit-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

