<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" version="2.0">

<channel>
	<title>Tinkerlog</title>
	
	<link>http://tinkerlog.com</link>
	<description>Alex' blog</description>
	<pubDate>Sun, 12 Jul 2009 21:15:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/tinkerlog" type="application/rss+xml" /><item>
		<title>Resistor cheat sticker</title>
		<link>http://tinkerlog.com/2009/07/05/resistor-cheat-sticker/</link>
		<comments>http://tinkerlog.com/2009/07/05/resistor-cheat-sticker/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 08:56:45 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<category><![CDATA[sticker]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=764</guid>
		<description><![CDATA[
While we were at cheating, here is a new sticker for your notebook. It helps you to read and learn resistor values.
The first 10 direct messages to me will get one for free. And of course every next order at the Tinker Store will include one of these.  
]]></description>
			<content:encoded><![CDATA[<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/07/l_dsc_0016.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/07/s_dsc_0016.jpg" alt="" title="Resistor cheat sticker" width="480" height="344" class="alignnone size-full wp-image-766" /></a></p>
<p>While we were at <a target="_blank" href="http://tinkerlog.com/2009/06/18/microcontroller-cheat-sheet/">cheating</a>, here is a new sticker for your notebook. It helps you to read and learn resistor values.</p>
<p>The first 10 direct messages to <a target="_blank" href="http://twitter.com/9600baud">me</a> will get one for free. And of course every next order at the <a href="http://store.tinkerlog.com/store/">Tinker Store</a> will include one of these.  </p>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/ggyq10Oxn0E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/07/05/resistor-cheat-sticker/feed/</wfw:commentRss>
		</item>
		<item>
		<title>64 Synchronizing Fireflies</title>
		<link>http://tinkerlog.com/2009/06/25/64-synchronizing-fireflies/</link>
		<comments>http://tinkerlog.com/2009/06/25/64-synchronizing-fireflies/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 09:27:09 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[avr]]></category>

		<category><![CDATA[led]]></category>

		<category><![CDATA[simulation]]></category>

		<category><![CDATA[firefly]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=760</guid>
		<description><![CDATA[
Last week I invested some time to solder 64 Firefly boards. Only 2.432 solder joints later I was ready for some videos. 
Every firefly acts completely autonomously, it has its own tiny controller, eye and luminary. They are all connected for power supply only. 

Here are some different configurations. 



Links

See how it&#8217;s done in the [...]]]></description>
			<content:encoded><![CDATA[<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5317886&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5317886&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p>Last week I invested some time to solder 64 <a target="_blank" href="http://tinkerlog.com/howto/synchronizing-firefly-how-to/">Firefly</a> boards. Only 2.432 solder joints later I was ready for some videos. </p>
<p>Every firefly acts completely autonomously, it has its own tiny controller, eye and luminary. They are all connected for power supply only. </p>
<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5318234&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5318234&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p>Here are some different configurations. </p>
<p><span id="more-760"></span></p>
<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5318396&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5318396&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5318548&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5318548&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<h3>Links</h3>
<ul>
<li>See how it&#8217;s done in the <a href="http://tinkerlog.com/howto/synchronizing-firefly-how-to/">Synchronizing Firefly Howto</a></li>
<li>Grab a <a href="http://store.tinkerlog.com/store/index.php?main_page=product_info&#038;cPath=2&#038;products_id=2">Firefly kit</a> at the Tinker Store</li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/SxlPJy-htkY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/06/25/64-synchronizing-fireflies/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Microcontroller cheat sheet</title>
		<link>http://tinkerlog.com/2009/06/18/microcontroller-cheat-sheet/</link>
		<comments>http://tinkerlog.com/2009/06/18/microcontroller-cheat-sheet/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 10:54:35 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[avr]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=752</guid>
		<description><![CDATA[
Often, when I am tinkering with a controller on a breadboard, I have to open up the according datasheet, only to look up the pinout. So I designed a simple page with all of of the pinouts that I use most. It has:

8-pin AVRs, ATtiny25/ATtiny45/ATtiny85
20-pin AVR, ATtiny2313
28-pin AVRs, ATmega48/ATmega88/ATmega168/ATmega328
Arduino to ATmega mapping
ISP header, 6-pin and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/micro-cheat-sheet.png" alt="" title="Microcontroller cheat sheet" width="470" height="578" class="alignnone size-full wp-image-755" /></p>
<p>Often, when I am tinkering with a controller on a breadboard, I have to open up the according datasheet, only to look up the pinout. So I designed a simple page with all of of the pinouts that I use most. It has:</p>
<ul>
<li>8-pin AVRs, ATtiny25/ATtiny45/ATtiny85</li>
<li>20-pin AVR, ATtiny2313</li>
<li>28-pin AVRs, ATmega48/ATmega88/ATmega168/ATmega328</li>
<li>Arduino to ATmega mapping</li>
<li>ISP header, 6-pin and 10-pin</li>
<li>FTDI-cable</li>
</ul>
<p>Maybe it&#8217;s helpful for others as well. You can download it as:</p>
<ul>
<li><a href='http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/micro-cheat-sheet.pdf'>micro-cheat-sheet.pdf</a></li>
<li><a href='http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/micro-cheat-sheet.svg'>micro-cheat-sheet.svg</a></li>
</ul>
<p>If you like it, you will also like the Tod&#8217;s cool <a target="_blank" href="http://todbot.com/blog/2009/05/23/arduino-chip-sticker-label/">Arduino chip sticker</a>.</p>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/LEwU0LYmgE8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/06/18/microcontroller-cheat-sheet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mini Braitenberg vehicle</title>
		<link>http://tinkerlog.com/2009/06/07/mini-braitenberg-vehicle/</link>
		<comments>http://tinkerlog.com/2009/06/07/mini-braitenberg-vehicle/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 12:40:28 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[braitenberg]]></category>

		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=737</guid>
		<description><![CDATA[
Here is the second incarnation of a Braitenberg vehicle. This one is almost half of the size of the previous one and it is programmed to &#8220;love&#8221;. That means it sticks to the light source and does not try to overrun it, as the &#8220;aggressive&#8221; first one.


If it is dark, then the two motors run [...]]]></description>
			<content:encoded><![CDATA[<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5029632&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5029632&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p>Here is the second incarnation of a <a target="_blank" href="http://en.wikipedia.org/wiki/Braitenberg_vehicle">Braitenberg</a> vehicle. This one is almost half of the size of the <a target="_blank" href="http://tinkerlog.com/2009/04/18/arduino-powered-braitenberg-vehicle/">previous one</a> and it is programmed to &#8220;love&#8221;. That means it sticks to the light source and does not try to overrun it, as the &#8220;aggressive&#8221; first one.</p>
<p><span id="more-737"></span></p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/l_dsc_0019.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/s_dsc_0019.jpg" alt="" title="Mini Braitenberg" width="480" height="343" class="alignnone size-full wp-image-742" /></a></p>
<p>If it is dark, then the two motors run at full speed. If a sensor detects light, it slows down the motor on the same side. So, if the right sensor detects more light than the left sensor, the right motor turns slower than the left one. That makes the vehicle turn right to the light source. If it is bright enough, both sensors will stop both motors. </p>
<h3>Parts</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/l_dsc_0027.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/s_dsc_0027.jpg" alt="" title="Two mini servos and a lipo cell" width="480" height="344" class="alignnone size-full wp-image-743" /></a></p>
<ul>
<li><a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=9220">Arduino Mini Pro</a> from Sparkfun</li>
<li><a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=7916">Mini breadboard</a> with 170 tie points from Sparkfun</li>
<li>2 mini servos, <a target="_blank" href="http://www.hobbycity.com/hobbycity/store/uh_viewItem.asp?idProduct=663&#038;Product_Name=HXT500_5g_/_.8kg_/_10sec_Micro_Servo">HXT500</a> from Hobbycity</li>
<li>2 <a target="_blank" href="http://www.solarbotics.com/products/gm10w/">GM10 wheels</a> from Solarbotics</li>
<li><a taget="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=341">3.7V LiPo cell with 800 mAh</a> from Sparkfun</li>
<li>2 Light Dependant Resistors (LDR)</li>
<li>2 10 k resitors</li>
<li>2 3 pin headers</li>
</ul>
<p>I picked the Arduino Mini Pro because of it&#8217;s size and because it runs at 3.3V, a good match with the 3.7V lipo cell. The lipo cell has about the same size as the mini breadboard. The two servos are hacked for continuous rotation and tied together, bottom to bottom with a piece of wire. Although most servos are rated for 5V, they work great with 3.7V. Maybe they run a bit slower.</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/l_dsc_0031.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/06/s_dsc_0031.jpg" alt="" title="Mini Braitenberg with his older brother" width="480" height="343" class="alignnone size-full wp-image-741" /></a></p>
<p>Here is the mini next to his older brother. The space on the mini breadboard is really limited, but it just works out. Still no soldering required, if you don&#8217;t count the servo hacking.</p>
<p>What&#8217;s next? Hm, pager motors?</p>
<h3>Links</h3>
<ul>
<li><a href="http://tinkerlog.com/2009/04/18/arduino-powered-braitenberg-vehicle/">Arduino powered Braitenberg vehicle</a></li>
<li><a target="_blank" href="http://en.wikipedia.org/wiki/Valentino_Braitenberg">Valentino Braitenberg</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/Ot9GjPjFpH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/06/07/mini-braitenberg-vehicle/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ATmega breadboard header</title>
		<link>http://tinkerlog.com/2009/05/23/atmega-breadboard-header/</link>
		<comments>http://tinkerlog.com/2009/05/23/atmega-breadboard-header/#comments</comments>
		<pubDate>Sat, 23 May 2009 14:59:24 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[avr]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=724</guid>
		<description><![CDATA[
This is another breadboard compatible header board, that I am working on. This one is for all 28-pin AVR devices, ATmega48, ATmega88, ATmega168 and the latest ATmega328. Component count is low and there is no voltage regulator on board. That makes it easy to power it from various sources.
As a bonus, this board is a [...]]]></description>
			<content:encoded><![CDATA[<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4796132&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4796132&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p>This is <a href="http://tinkerlog.com/2009/01/18/attiny-breadboard-headers/">another</a> breadboard compatible header board, that I am working on. This one is for all 28-pin AVR devices, ATmega48, ATmega88, ATmega168 and the latest ATmega328. Component count is low and there is no voltage regulator on board. That makes it easy to power it from various sources.</p>
<p>As a bonus, this board is a hybrid of through hole and SMT components. It has two SMD LEDs under the hood. Great to learn how to solder surface mounted devices.</p>
<p><span id="more-724"></span></p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_dsc_00211.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_00211.jpg" alt="" title="mega168 header board" width="480" height="344" class="alignnone size-full wp-image-731" /></a></p>
<p>It has also an FTDI-connector and runs with a 16 MHz resonator, which makes it Arduino compatible. The jumper is used to select between different power sources.</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_imgp0004.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_imgp0004.jpg" alt="" title="SMD LEDs and resistors, noob soldering" width="480" height="343" class="alignnone size-full wp-image-727" /></a></p>
<p>Yikes, SMD soldering. This is my first attempt at hand soldering 1206 <a href="http://en.wikipedia.org/wiki/Surface-mount_technology" target="_blank">SMT</a> components. 1206 is only 3.2 mm × 1.6 mm! But these are about the largest SMT components available. Most commonly used are way smaller, 0805, 0603 or 0402. My soldering still looks ugly, but with a bit of practice I think I can do much better.</p>
<p>The space on the board is a bit limitted, so there is no room to mark all pins. That&#8217;s why I have a little cheat sheet around, while wiring things up.</p>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/GwgxY_KYHDc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/05/23/atmega-breadboard-header/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interfacing Arduino with a Telit GM862</title>
		<link>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/</link>
		<comments>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/#comments</comments>
		<pubDate>Fri, 15 May 2009 17:59:52 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[gps]]></category>

		<category><![CDATA[gsm]]></category>

		<category><![CDATA[GM862-GPS]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=704</guid>
		<description><![CDATA[
The Arduino can talk over a wide range of networks. Ethernet, Bluetooth, Wifi, XBEE and GPRS to name the most known. I had a Telit GM862-GPS module laying around, unused for some time already. It has GPRS and GPS capabilities, both accessible with AT commands. So I decided to port some of my code to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0005.jpg" alt="" title="Telit GM862-GPS" width="480" height="343" class="alignnone size-full wp-image-705" /></p>
<p>The Arduino can talk over a wide range of networks. Ethernet, Bluetooth, Wifi, XBEE and GPRS to name the most known. I had a <a target="_blank" href="http://www.telit.com/en/products/gsm-gprs.php?p_id=12&#038;p_ac=show&#038;p=7">Telit GM862-GPS</a> module laying <a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">around</a>, unused for some time already. It has GPRS and GPS capabilities, both accessible with AT commands. So I decided to port some of my code to the Arduino.</p>
<p><span id="more-704"></span></p>
<h3>Schematic</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_gm862.png"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_gm862.png" alt="" title="Schematic GM862 with Arduino Mega" width="490" height="240" class="alignnone size-full wp-image-706" /></a></p>
<p>Connecting the Arduino Mega to the GM862 is rather easy. Only four connections are needed.</p>
<ul>
<li>Tx3 - Tx</li>
<li>Rx3 - Rx</li>
<li>Pin 22 - On/Off</li>
<li>GND - GND</li>
</ul>
<p>The GM862 is accessed with a breadboard fiendly breakout board from <a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=277">Sparkfun</a>.</p>
<p>The logic pins of the GM862 accept only CMOS 2.8 Volt. For that reason, a voltage divider is needed for the Tx line. Both, Rx and Tx are pulled up to the PWR_CTL line of the module because these pins don&#8217;t have an internal pull up resistor.<br />
The on/off line is connected to ground with a transistor.</p>
<p>The bad thing for this setup is the power supply. The module is powered by a LiPo cell (3.7 V with 2000 mAh). The Arduino Mega is powered by the USB port. If I want to make this portable, I have to use two batteries.  Or find a better solution. Maybe powering the Arduino with a step-up converter. </p>
<h3>Software</h3>
<p>First I wanted to use an Arduino Pro mini, that runs on 3.3 V. That would save me from having two different power supplies for the Arduino and the GM862. I tried to connect the Rx/Tx lines to two digital pins and use the <a target="_blank" href="http://arduiniana.org/">NewSoftSerial</a> library. This library enables a second serial port on the Arduino besides the hardware serial port. Unfortunately it wasn&#8217;t reliable enough. Sending to the module seems to work well, receiving sometimes did not. I tried it with different baud rates and different Arduinos, 8 MHz and 16 MHz, but that didn&#8217;t help. Maybe I did something wrong, but I couldn&#8217;t figure it out.<br />
So I switched to my brand new Arduino Mega. I just connected Rx/Tx to one of the hardware serial ports and it worked immediatly.</p>
<p>The following features are implemented:</p>
<ul>
<li>Starting and stopping the module</li>
<li>Initialization</li>
<li>Sending of SMS</li>
<li>Requesting GPS position and parsing the result</li>
<li>Opening a socket, writing and reading (used to talk HTTP) over GPRS</li>
</ul>
<p>The software is an really early stage. I focussed most on functionality and less on performance or compact code.  The following todos are still open:</p>
<ul>
<li>Make debugging output configurable</li>
<li>Use of PROGMEM to reduce RAM usage</li>
<li>More compact structure for AT commands</li>
<li>Parse more responses of AT commands. Some are simply issued, without looking at the response</li>
</ul>
<p>Nevertheless, here is a small snippet, that shows features that are already working. To get it working, you have to replace XXXX with your PIN. For GPRS you have to dig into the module code and adapt the GPRS settings.</p>
<pre name="code" class="c">
/*
 * GM862-GPS testing sketch
 * used with Arduino Mega
 * http://tinkerlog.com
 */

#include "GM862.h"

int onPin = 22;                      // pin to toggle the modem's on/off
char PIN[5] = "XXXX";                // replace this with your PIN
Position position;                   // stores the GPS position
GM862 modem(&#038;Serial3, onPin, PIN);   // modem is connected to Serial3
char cmd;                            // command read from terminal

void setup() {
  delay(10000);
  Serial.begin(19200);
  Serial.println("GM862 monitor");
  modem.switchOn();                   // switch the modem on
  delay(4000);                        // wait for the modem to boot
  modem.init();                       // initialize the GM862
  modem.version();                    // request modem version info
  while (!modem.isRegistered()) {
    delay(1000);
    modem.checkNetwork();             // check the network availability
  }
  Serial.println("---------------------");
  Serial.println("ready");
}

void requestHTTP() {
  char buf[100];
  byte i = 0;
  modem.initGPRS();                   // setup of GPRS context
  modem.enableGPRS();                 // switch GPRS on
  modem.openHTTP("search.twitter.com");    // open a socket
  Serial.println("sending request ...");
  modem.send("GET /search.atom?q=gm862 HTTP/1.1\r\n"); // search twitter for gm862
  modem.send("HOST: search.twitter.com port\r\n");     // write on the socket
  modem.send("\r\n");
  Serial.println("receiving ...");
  while (i++ < 10) {                  // try to read for 10s
    modem.receive(buf);               // read from the socket, timeout 1s
    if (strlen(buf) > 0) {            // we received something
      Serial.print("buf:"); Serial.println(buf);
      i--;                            // reset the timeout
    }
  }
  Serial.println("done");
  modem.disableGPRS();                // switch GPRS off
}

void loop() {
  if (Serial.available()) {
    cmd = Serial.read();
    switch (cmd) {
    case 'o':
      modem.switchOff();              // switch the modem off
      break;
    case 's':                         // send a SMS. Replace with your number
      modem.sendSMS("6245", "your@email.com hello from arduino");
      break;
    case 'w':
      modem.warmStartGPS();           // issue a GPS warmstart
      break;
    case 'p':
      position = modem.requestGPS();  // request a GPS position
      if (position.fix == 0) {        // GPS position is not fixed
        Serial.println("no fix");
      }
      else {                          // print lat, lon, alt
        Serial.print("GPS position: ");
        Serial.print(position.lat_deg);  Serial.print(".");
        Serial.print(position.lat_min);  Serial.print(", ");
        Serial.print(position.lon_deg);  Serial.print(".");
        Serial.print(position.lon_min);  Serial.print(", ");
        Serial.println(position.alt);
      }
      break;
    case 'h':
      requestHTTP();                  // do a sample HTTP request
      break;
    default:
      Serial.println("command not recognized");
    }
  }
}
</pre>
<h3>Log</h3>
<p>Here is a log, that I recorded within the Arduino IDE. You can see, how</p>
<ul>
<li>the modem gets switched on</li>
<li>the modem gets initialized</li>
<li>the version info is requested</li>
<li>it waits until the network is reachable</li>
<li>a GPS position is requested</li>
<li>a SMS gets send</li>
<li>how a HTTP GET is issued over GPRS, it searches for gm862 on twitter</li>
</ul>
<pre>
GM862 monitor
switching on
done
initializing modem ...
AT
->ok
AT+IPR=19200
->ok
AT+CMEE=2
->ok
AT+CPIN=XXXX
->ok
done
version info ...
AT+GMI
->buf: AT+GMI
Telit
OK
AT+GMM
->buf: AT+GMM
GM862-GPS
OK
AT+GMR
->buf: AT+GMR
07.02.403
OK
AT+CSQ
->buf: AT+CSQ
+CSQ: 0,0
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,2
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,2
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,1
OK
done

---------------------
ready

requesting GPS position ...
AT$GPSACP
->buf: AT$GPSACP
$GPSACP: 110621.999,5333.9477N,00954.8735E,1.4,66.3,3,22.21,0.10,0.05,150509,08
OK
3
GPS position: 53.565794, 9.914568, 66

sending SMS ...
AT+CMGF=1
->ok
AT+CMGS="6245"
->not ok: AT+CMGS="6245"
>
your@email.com hello from arduino
done

initializing GPRS ...
AT+CGDCONT=1,"IP","internet","0.0.0.0",0,0
->buf:
+CMGS:  35
OK
AT+CGDCONT=1,"IP","internet","0.0.0.0",0,0
OK
AT#USERID=""
->buf: AT#USERID=""
OK
AT#PASSW=""
->buf: AT#PASSW=""
OK
done

switching GPRS on ...
AT#GPRS=1
->buf: AT#GPRS=1
+IP: 10.37.146.251
OK
done

opening socket ...
AT#SKTD=0,80,"search.twitter.com",0,0
->buf: AT#SKTD=0,80,"search.twitter.com",0,0
buf:
buf:
CONNECT
sending request ...
receiving ...
buf:HTTP/1.1 200 OK
Date: Fri, 15 May 2009 11:07:19 GMT
Server: hi
Status: 200 OK
Cache-Control: ma
buf:x-age=20, must-revalidate, max-age=1800
Content-Type: application/atom+xml; charset=utf-8
X-Serve
buf:d-By: searchweb005.twitter.com
Expires: Fri, 15 May 2009 11:37:18 GMT
Content-Length: 4757
Vary:
buf: Accept-Encoding
X-Varnish: 218274860
Age: 0
Via: 1.1 varnish
X-Cache-Svr: searchweb005.twitter
buf:.com
X-Cache: MISS
Connection: close

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
[...]
    &lt;/author&gt;
  &lt;/entry&gt;
&lt;/feed&gt;

NO CARRIER
done

switching GPRS off ...
AT#GPRS=0
->buf: AT#GPRS=0
OK
done
</pre>
<h3>Outlook</h3>
<p>Besides some software todos on the list, two things are still bugging me. One is the need of an Arduino Mega because of the hardware serial port. I will try the new version of NewSoftSerial, as soon as it is released. The other thing is the need of two power sources. But that could be solved with the Arduino Mini pro, when the software serial issue is fixed.</p>
<p>Everything else worked well. Now I only need a problem that could be solved with this <img src='http://tinkerlog.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<h3>Links and Downloads</h3>
<ul>
<li>Source code: <a href='http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/arduino-gm862.zip'>arduino-gm862.zip</a></li>
<li><a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">Interfacing an AVR controller to a GPS Mobile Phone</a></li>
<li><a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=277">GM862 breakout board</a> from Sparkfun</li>
<li><a target="_blank" href="http://www.telit.co.it/modulef.asp?famId=7&#038;famName=GM862%20Modem%20Family">GM862 specs</a> at Telit.</li>
<li><a target="_blank" href="http://www.roundsolutions.de">roundsolutions</a>, distributor for GM862 modules.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/rLJLOm4miJw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tupperware Arcade Controls</title>
		<link>http://tinkerlog.com/2009/05/08/tupperware-arcade-controls/</link>
		<comments>http://tinkerlog.com/2009/05/08/tupperware-arcade-controls/#comments</comments>
		<pubDate>Fri, 08 May 2009 16:25:48 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[avr]]></category>

		<category><![CDATA[arcade]]></category>

		<category><![CDATA[hid]]></category>

		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=670</guid>
		<description><![CDATA[
If you want to play some retro arcade games, you will install the amazing MAME and run your favorite ROM. One of my best-of-all-times is Bomb Jack. 
But you have to play it with the keyboard. Bah! 
Or an USB game pad. Better, but still &#8212; bah!
Nothing compares to real arcade controls. And with a [...]]]></description>
			<content:encoded><![CDATA[<p><object width="490" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4543912&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4543912&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="490" height="282"></embed></object></p>
<p>If you want to play some retro arcade games, you will install the amazing MAME and run your favorite ROM. One of my best-of-all-times is <a href="http://www.klov.com/game_detail.php?game_id=7180&#038;letter=B" target="_blank">Bomb Jack</a>. </p>
<p>But you have to play it with the keyboard. Bah! </p>
<p>Or an USB game pad. Better, but still &#8212; bah!</p>
<p>Nothing compares to real arcade controls. And with a bit of tinkering, you can get a tiny step closer to the real gaming experience. </p>
<p><span id="more-670"></span></p>
<h3>USB HID</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_dsc_0013.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0013.jpg" alt="" title="Tupperware Arcade controls" width="480" height="343" class="alignnone size-full wp-image-688" /></a></p>
<p><a href="http://en.wikipedia.org/wiki/USB_Human_Interface_Device_class" target="_blank">HID</a> stands for Human Interface Device class. Common devices of this class are keyboards, mice and joysticks. The great thing, that this interface brings in, is, the devices don&#8217;t need a specific device driver. If they behave according to the <a href="http://www.usb.org/developers/hidpage/" target="_blank">USB HID spec</a>, then they are automatically recognized by all OSs. Every device sends a report, in which it states, which kind of device it is and how it wants to report its data.</p>
<p>The next great part is the fantastic USB driver <a href="http://www.obdev.at/products/vusb/index.html" target="_blank">V-USB</a> that is developed by Objective Development. This driver can be run on most of all Atmel AVR controllers, even on ATtinys. It does not require any other chip, only a couple of standard components. The library is licensed under GPL, a commercial license is available as well.  </p>
<h3>Needed components</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_dsc_0029.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0029.jpg" alt="" title="Arcade button" width="480" height="344" class="alignnone size-full wp-image-687" /></a></p>
<p>I ordered my arcade controls at <a href="http://www.arcadeshop.de/"  target="_blank">ArcadeShop.de</a>, a german shop for Arcade parts. The joystick is great. Heavy and solid. And makes nice clicks. </p>
<p>The buttons, that I ordered are ok. They are working fine but seem to be a bit too small. They have a diameter of 27 mm. Next time I would take bigger ones.</p>
<p>Nothing special about the rest of the needed parts. A breadboard, an ATmega48 and a couple of resistors, capacitors and diodes. And of course a plastic box as enclosure. Keeps the electrons fresh. BTW, mine is not Tupperware, but super cheap IKEA.</p>
<h3>The circuit</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_mame_controls.png"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/mame_controls.png" alt="" title="Arcade controls circuit" width="482" height="336" class="alignnone size-full wp-image-691" /></a></p>
<p>The circuit is almost one of the standard setups, that Obdev recommends. I used 47 Ohm instead of 68 Ohm for R2 and R3 because I had them laying around. The two 1N4148 diodes reduce the supply from 5 V to about 3.6 V. This is a &#8220;poor mans&#8221; voltage regulator. A better solution would be a low drop 3.3 V voltage regulator. But for prototyping the two diodes will do the job.</p>
<p>First I tried to run it with a 16 MHz crystal. I thought that it should be enough to change the F_CPU setting, but that didn&#8217;t work out. The device was not recognized. When I switched to the 12 MHz crystal it worked almost at once.</p>
<p>All controls, the stick and the buttons, are connected to the controller and to ground. Therefor the internal pull-up resistors have to be enabled.</p>
<h3>Firmware</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_dsc_0021.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0021.jpg" alt="" title="USB-HID circuit on a breadboard" width="480" height="322" class="alignnone size-full wp-image-684" /></a></p>
<p>The firmware is based on the examples provided at the V-USB page. Two projects, that I played with are the <a href="http://www.obdev.at/products/vusb/prjdetail.php?pid=5"  target="_blank">HIDKeys</a> example and the <a href="http://hobbyelektronik.org/wiki/index.php?title=SNES-Joypad"  target="_blank">SNES-Joypad</a>. The first one is used to build a simple keyboard. The second was made to play emulated SNES games with a SNES pad.</p>
<p>The biggest problem was to find a matching USB HID report descriptor. This descriptor is used to tell the PC, what kind of device is attached to the USB port and what kind of data it sends. At the moment I am using the &#8220;Game Pad&#8221; device class. </p>
<h3>Conclusion</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_dsc_0030.jpg"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0030.jpg" alt="" title="Tupperware arcade controls" width="480" height="398" class="alignnone size-full wp-image-681" /></a></p>
<p>This is a work in progress. The plastic box works but is way too wobbly. It was more of a joke. The next version should have a more sturdy enclosure. And the circuit should be more permanent and not that place consuming. </p>
<p>I am planning to have a two player version (Gauntlet!). For that I am still unsure, if I should switch to the USB-HID keyboard class. Or maybe implement two gamepads with one controller. We will see.</p>
<p>Over all, it&#8217;s great to play some of the old games again. Even if this is nothing compared to a real cabinet.</p>
<h3>Links and Downloads</h3>
<ul>
<li>Firmware: <a href='http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/mame_controller.zip'>mame_controller.zip</a></li>
<li><a href="http://mamedev.org/" target="_blank">MAME</a>, Multi Arcade Machine Emulator</li>
<li><a href="http://www.obdev.at/products/vusb/index.html" target="_blank">V-USB (formerly know as AVR-USB)</a> developed by Objective Development
<li><a href="http://hobbyelektronik.org/wiki/index.php?title=SNES-Joypad" target="_blank">SNES-Joypad</a> using V-USB (german)</li>
<li><a href="http://www.usb.org/developers/hidpage/" target="_blank">USB HID</a> page at USB.org</li>
<li>Arcade controls at <a href="http://www.arcadeshop.de" target="_blank">ArcadeShop.de</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/cYSlyN865N8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/05/08/tupperware-arcade-controls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Arduino powered Braitenberg vehicle</title>
		<link>http://tinkerlog.com/2009/04/18/arduino-powered-braitenberg-vehicle/</link>
		<comments>http://tinkerlog.com/2009/04/18/arduino-powered-braitenberg-vehicle/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 16:38:04 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[sensor]]></category>

		<category><![CDATA[braitenberg]]></category>

		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=613</guid>
		<description><![CDATA[
Jonathan asked me, if I would like to do a project with him on Braitenberg vehicles. After some research and reading the first couple of chapters in Vehicles: Experiments in Synthetic Psychology, I was hooked in. Here is the first version of a Braitenberg vehicle, powered with two RC-Servos and an Arduino as its brain.
Best [...]]]></description>
			<content:encoded><![CDATA[<p><object width="441" height="254"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4212409&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4212409&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="441" height="254"></embed></object></p>
<p><a href="http://www.optokopter.com">Jonathan</a> asked me, if I would like to do a project with him on Braitenberg vehicles. After some research and reading the first couple of chapters in <a href="http://www.amazon.com/Vehicles-Experiments-Psychology-Valentino-Braitenberg/dp/0262521121">Vehicles: Experiments in Synthetic Psychology</a>, I was hooked in. Here is the first version of a Braitenberg vehicle, powered with two RC-Servos and an Arduino as its brain.</p>
<p>Best of all, it needs no soldering, drilling or hot glue. And if you&#8217;ve played already with Arduinos, there is a good chance, that you have already most of the needed parts at home..</p>
<p><span id="more-613"></span></p>
<h3>Braitenberg vehicles</h3>
<p><img class="alignnone size-full wp-image-615" title="Braitenberg vehicle, turning towards the light source" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/braitenberg.png" alt="" width="450" height="398" /></p>
<p><a href="http://en.wikipedia.org/wiki/Valentino_Braitenberg">Valentino Braitenberg</a> developed a model of simple vehicles with sensors and actuators (motors) and interconnections between them. While the vehicles are extremely simple, the emerging behaviour is not. It is often interpreted as love, aggression or caution.</p>
<p>The easiest one is a light seeking vehicle. That&#8217;s like &#8220;hello world&#8221; in robotics. The sensors are affecting directly the motors. The right sensor affects the left motor and the left sensor affects the right motor. That means, if light shines on the right sensor, the left wheel turns. And if the light shines brighter on the right sensor, the left motor will turn faster than the left one and so the vehicle will turn towards the light source.</p>
<p>These kind of simple robots can be build with analog techniques alone, they don&#8217;t need a microcontroller. Think of two sensors feeding into two amplifiers that control the motors. The big advantage a controller brings in, is the possibility to rewire the connections between inputs and outputs in software. Even more complex functions for the interconnections can be reprogrammed easily.</p>
<h3>Needed parts</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0006a.jpg"><img class="alignnone size-full wp-image-637" title="Parts for a Braitenberg vehicle" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0006a.jpg" alt="" width="480" height="344" /></a></p>
<ul>
<li>Arduino board</li>
<li>small breadboard or prototyping Arduino shield</li>
<li>2 RC-servos, can be cheap</li>
<li>2 wheels, <a href="http://www.solarbotics.com/products/gmpw/">Solarbotics</a></li>
<li>2 light sensors, LDR (Light Dependent Resistor), e.g. <a href="http://www.solarbotics.com/products/cds/">CdS from Solarbotics</a>, and 2 resistors</li>
<li>2 3-pin headers</li>
<li>battery holder and 4 rechargeable batteries</li>
<li>some rubber bands</li>
<li>some wires</li>
<li>paper clip</li>
</ul>
<p>I am using a <a href="http://www.ladyada.net/make/boarduino/">Boarduino</a> here, that snaps nicely into the small breadboard. The two wheels are used for convenience. You could use any other type of wheels and attach them to the servos.</p>
<p>The two resistors have to match the LDRs to form a good voltage divider. Otherwise you get only a small range of values out of your sensors. Mine work great with a 10 k resistor.</p>
<p>The servos are hacked. Hacking servos means modifying them for continuous motion. A standard servo moves its tiny arm around from -90 to +90 degrees. But we want them to act as simple motors. There are quite a number of resources out there on how to hack a servo. One of the latest and very good documented one is from Tod. Check out his post about <a href="http://todbot.com/blog/2009/04/11/tiny-servos-as-continuous-rotation-gearmotors/">&#8220;Tiny Servos as Continuous Rotation Gearmotors&#8221;</a>.</p>
<h3>Tools</h3>
<p>Nothing. Ha, no soldering iron, no drilling and no hot glue! Ok, you need a PC and an USB-cable.</p>
<h3>Assembling</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0005a.jpg"><img class="alignnone size-full wp-image-633" title="Breadboard with Boarduino and servos" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0005a.jpg" alt="" width="480" height="343" /></a></p>
<p>Attach the two servos to the breadboard by using 3-pin headers. Connect the red cable to VCC and the brown one to GND. The orange cable is used to send the control pulses to the servo motor. It is connected to Arduino pin 10 (left) and 9 (right).</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0013.jpg"><img class="alignnone size-full wp-image-641" style="margin: 5px;" title="left side" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/t_dsc_0013.jpg" alt="" width="220" height="148" /></a><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0015.jpg"><img class="alignnone size-full wp-image-642" style="margin: 5px;" title="right side" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/t_dsc_0015.jpg" alt="" width="220" height="148" /></a></p>
<p>The LDR and the resistor are forming a voltage divider. Connect the LDR to VCC and to a free socket on the breadboard. Now connect the resistor to GND and a free socket of the same row as the LDR. Next connect a wire from this row to the analog input pins of the Arduino (left to analog 0 and right to analog 1).</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0008.jpg"><img class="alignnone size-full wp-image-625" title="Rubber band to hold everything in place" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0008.jpg" alt="" width="480" height="344" /></a></p>
<p>Now take the two servos, put them together and wrap a rubber band around them and the breadboard. Then attach the battery holder to the breadboard and fix it with another rubber band.</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0020.jpg"><img class="alignnone size-full wp-image-632" title="Tail" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0020.jpg" alt="" width="480" height="343" /></a></p>
<p>Use the paperclip or some other kind of wire to form a small hook. The hook should snap into place and holding the breadboard and the battery holder together. And it has a little notch that is used instead of a third wheel.</p>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0003.jpg"><img class="alignnone size-full wp-image-636" title="Waiting for a brain" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0003.jpg" alt="" width="480" height="343" /></a></p>
<p>Now this tiny guy is complete.</p>
<h3>Arduino Code</h3>
<pre name="code" class="c">
/*
 * Simple braitenberg vehicle
 * http://tinkerlog.com
 */

#include "Servo.h"

Servo leftServo;
Servo rightServo;
int leftValue = 0;
int rightValue = 0;

void setup() {
  leftServo.attach(10);
  rightServo.attach(9);
} 

void loop() {
  // sensor values between 50..900
  leftValue = (analogRead(0) - 50) / 50;
  rightValue = (analogRead(1) - 50) / 50;
  leftServo.write(89 + rightValue);
  rightServo.write(89 - leftValue);
  delay(10);
}</pre>
<p>Yes, that&#8217;s all it needs. Only 25 lines of code. Including comments.</p>
<p>The analog values of the sensors are in a range between 50 and 900. So we take 50 as 0 and scale the value down.</p>
<p>The value you send to the servo is the degree it should turn to. From 0 to 180 degrees. At 90 degrees it is centered. For me, 89 is the value at which the left and the right servo stands still. If we add a value, the servo motors spins forward, if we subtract a value, it spins backward. The function for the right servo subtracts the values because it is attached on the opposite side.</p>
<p>You might have to write some simple sketches to evaluate the right values of the sensors and servo motors.</p>
<p>If you plug the USB cable into your PC, it may suck too much power because of the servo motors. You  can power it with your external battery pack. Check your Arduino board, most have a jumper for external power supply. Or you unplug the servos for programming.</p>
<h3>Play</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/b_dsc_0005.jpg"><img class="alignnone size-full wp-image-630" title="Ready to roll" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_dsc_0005.jpg" alt="" width="480" height="360" /></a></p>
<p>Now switch him on and see if he finds some light sources. It works better, if the rest of the room is dark with only a single light source. I managed to tempt him with a flash light or a lighter. If he seems not to turn as much as he should, try to bend the light sensors more sideways.</p>
<p>This small bot is a bit shaky because of the rubber bands. But he is forgiving. And as he moves around underneath your table, you almost instantly think of him as something that has its own will. Even if you know, that it has only two sensors and two motors.</p>
<h3>Links</h3>
<ul>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Valentino_Braitenberg">Valentino Braitenberg</a></li>
<li>Amazon: <a href="http://www.amazon.com/Vehicles-Experiments-Psychology-Valentino-Braitenberg/dp/0262521121">Vehicles: Experiments in Synthetic Psychology</a></li>
<li>Video of Jonathan&#8217;s <a href="http://www.vimeo.com/2755217">vehicles</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/YQLbN8LeHzk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/04/18/arduino-powered-braitenberg-vehicle/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Solar powered 64pixels</title>
		<link>http://tinkerlog.com/2009/04/17/solar-powered-64pixels/</link>
		<comments>http://tinkerlog.com/2009/04/17/solar-powered-64pixels/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:44:38 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[avr]]></category>

		<category><![CDATA[64pixels]]></category>

		<category><![CDATA[Solar]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=603</guid>
		<description><![CDATA[
Jonathan bought a 64pixels kit and modded it into a green version. The three solar cells, that he uses are rated with: 2.7 volts (open circuit) @ 15mA (short circuit). He writes, it works well in bright sun light. His desktop lamp shines with 60 Watts and that seems to work as well.


He also used [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-604" title="64pixels with solar cells" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/img_9698.jpg" alt="" width="500" height="375" /></p>
<p><a href="http://www.optokopter.com/">Jonathan</a> bought a <a href="http://store.tinkerlog.com/store/index.php?main_page=product_info&amp;cPath=4&amp;products_id=9">64pixels kit</a> and modded it into a green version. The three solar cells, that he uses are rated with: 2.7 volts (open circuit) @ 15mA (short circuit). He writes, it works well in bright sun light. His desktop lamp shines with 60 Watts and that seems to work as well.</p>
<p><span id="more-603"></span></p>
<p><img class="alignnone size-full wp-image-605" title="A socket attached to the matrix display" src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/img_9696.jpg" alt="" width="500" height="375" /></p>
<p>He also used a socket to be able to pop out the controller, whenever he wants to program new messages or animations.<br />
Well done!</p>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/23nvpmbdQ2w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/04/17/solar-powered-64pixels/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Driving an LED with or without a resistor</title>
		<link>http://tinkerlog.com/2009/04/05/driving-an-led-with-or-without-a-resistor/</link>
		<comments>http://tinkerlog.com/2009/04/05/driving-an-led-with-or-without-a-resistor/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 13:27:05 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
		
		<category><![CDATA[avr]]></category>

		<category><![CDATA[led]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=579</guid>
		<description><![CDATA[In this post I will try to show, why it&#8217;s a good idea to use a current limiting resistor for an LED. And when it&#8217;s save to drive the LED without any resistor.
If you read about LEDs, you will notice that everyone tells you, that you need a current limiting resistor. But mostly they do [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will try to show, why it&#8217;s a good idea to use a current limiting resistor for an LED. And when it&#8217;s save to drive the LED without any resistor.</p>
<p>If you read about LEDs, you will notice that everyone tells you, that you need a current limiting resistor. But mostly they do not tell you why.</p>
<h3>LED with current limiting resistor</h3>
<p>If you look at a datasheet of an LED, you will notice that graphs shown are not linear. An LED is a diode, a semiconductor and behaves differently compared to a resistor.</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/s_led-res.png" alt="" title="Resitor and LED" width="480" height="267" class="alignnone size-full wp-image-583" /></p>
<p>If you apply a specific voltage to a resistor, you can compute the resulting current with:</p>
<p><code><br />
I = V / R  Example: I = 5 Volt / 100 Ohm = 50 mA<br />
</code></p>
<p><span id="more-579"></span></p>
<p>Obviously that does not work with LEDs because they don&#8217;t behave like a linear resistor. If you look at the graph above, you can rise the voltage from 0 Volt to 1.6 Volt without resulting in noticeable current. Apply a bit more voltage and there is current and the LED lights up. We have reached the Forward Voltage which is needed to open the pn-gate. Forward Voltage (VF) for a typical red LED is 1.7 to 2.2 Volt. Now small changes in the voltage produce large effects on the resulting forward current (IF). Datasheets normally state at least the absolute maximum ratings for IF, eg. 25 mA. If you apply a voltage that results in a larger current, the LED may be destroyed. </p>
<p>So it&#8217;s vital to stay within the limits of the LED. If you would attach an LED to a 5 Volt power supply directly, you would burn it instantly. The high current would destroy the pn-gate. That&#8217;s the point where the current limiting resistor comes in.</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/resistor_led1.png" alt="" title="LED with current limitting resistor" width="400" height="311" class="alignnone size-full wp-image-587" /></p>
<p>Assuming, we have a red LED with maximum rating of IF: 25 mA at VF: 2.1 Volt. Its VF related to IF is like the curve in the graph at the top. If we want to use it at 5 Volt, we have to use a resistor to dissipate the remaining 2.9 Volt. To compute the resitor, we use:</p>
<p><code><br />
R = V / I = (5 Volt - 2.1 Volt) / 25 mA = 116 Ohm.<br />
</code></p>
<p>To be safe we use a 120, or better, 150 Ohm resistor. That way we don&#8217;t drive the LED near it&#8217;s maximum rating. We choose 20 mA, take a look at the curve and see a corresponding VF of 2 Volts. Now we recalculate the resistor.</p>
<p><code><br />
R = V / I = (5 Volt - 2 Volt) / 20 mA = 150 Ohm.<br />
</code></p>
<p>Ok, 150 Ohm is fine. To be safe with the resistor, we have to take a look at the power dissipation. It calculates as:</p>
<p><code><br />
P = V * I = 3 Volt * 20 mA = 60 mW<br />
</code></p>
<p>So it&#8217;s safe to choose a 150 Ohm resistor with 1/4 Watt rating.</p>
<p>Ok, so far the typical use of an LED with an current limitting resistor.</p>
<h3>LED without current limitting resistor</h3>
<p>First of all, why would you want to get rid of the resistor? There are two reasons. First is, it wastes energy. It converts electrical energy into heat. But we want to light up an LED. Not good. Second is, you can reduce the number of components. The circuit gets cheaper, because we saved a resistor and maybe space on a PCB.</p>
<p>There are two ways to bypass the resistor. One way is to lower the input voltage. If you are able to run your complete circuit with the same voltage as forward voltage of the LED, perfect. No resistor needed. </p>
<p>Another method is to use pulse width modulation (PWM). That means we are switching the LED on and off. If we are switching fast enough, the human eye can not tell the difference. It integrates the brightness over time, so to speak. Often there is a Peak Forward Current (IF(peak)) rating in the datasheet. As an example:</p>
<blockquote><p>
IF(peak) = 160 mA<br />
Condition: Pulse Width <= 1 msec and Duty <= 1/10
</p></blockquote>
<p>Which means, it is safe to switch the LED with 1 kHz, where the LED is on for 1 msec and off for 9 msecs.</p>
<p>Most of the times there is no voltage given for IF(peak), so we can not be sure at what voltage we will reach the 160 mA in the example. Looking at the graph, I would assume that you could go up to 3 V, maybe 3.2 V, but I haven&#8217;t tested it out.</p>
<p>I used both methods for my <a href="http://tinkerlog.com/howto/64pixels/">64pixels</a>, where I attached an LED matrix directly to a microcontroller without any current limitting resistors.</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/dsc_0061.jpg" alt="" title="LED matrix attached directly to an ATtiny2313" width="480" height="343" class="alignnone size-full wp-image-591" /></p>
<p>The input voltage is 3 Volts, if used with 2 AA batteries or about 2.4 Volts with 2 AA rechargeables. That helps to get closer to VF of the LEDs. </p>
<p>The matrix lets you address only one row at a time. So you set all column bits for row one and enable row one. Then you disable row one, set all bits for row two and enable row two, and so on. So you are cycling through all rows. This is done so fast, that you wont see any flickering. Every row is updated with nearly 2 kHz and with a duty cycle of 1/8 (because of the 8 rows).</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/ledwmicro.png" alt="" title="LED with source and sink pins" width="440" height="303" class="alignnone size-full wp-image-589" /></p>
<p>If you are using a microcontroller for driving an LED or LED matrix, you have to take care of the current ratings of the microcontroller as well. Every I/O pin can only deliver (source) or receive (sink) a specific amount of current. I used an ATtiny2313 and from the datasheet on page 181, I read </p>
<blockquote><p>Absolute Maximum Ratings:<br />
* DC Current per I/O pin: 40.0 mA
</p></blockquote>
<p>And on page 182 as a note:</p>
<blockquote><p>4. Although each I/O port can sink more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed: 1] The sum of all IOL, for all ports, should not exceed 60 mA. If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.
</p></blockquote>
<p>As I understand that, if you are trying to source or sink more than 10 mA, the voltage VOL (Output Low Voltage) or VOH (Output High-voltage) may drop or rise and exeed the specified values.</p>
<p>Looking at two graphs from the datasheet may help to clear things up.</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/fig106.png" alt="" title="Source current vs. Output voltage (used with permission)." width="480" height="328" class="alignnone size-full wp-image-592" /></p>
<p>This figure shows how the output voltage of a source pin is related to the current that it sources at 2.7 V input voltage. 2.7 is not 3 Volts as 2 AA cells can deliver, but close enough for now. What we see, is that the output voltage drops, if we demand more and more current. At 5 mA we have a voltage of 2.5 Volts, but at 15 mA the voltage drops to 2.1 Volts.</p>
<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/04/fig109.png" alt="" title="Sink current vs. Ouput Voltage (used with permission)" width="480" height="315" class="alignnone size-full wp-image-593" /></p>
<p>This figure shows how the output voltage of a sink pin is related to the current that it sinks. This time the ouput voltage rises, if we demand the pin to sink more current. At 5 mA the voltage is 0.15 Volts but rises to 0.5 Volts at 15 mA.</p>
<p>To check if we are using the ATtiny2313 and the matrix within their specifications, we have to do some math. For the matrix, there is no datasheet with nice graphs but some numbers.</p>
<blockquote><p>
Forward Voltage: 1.80 - 2.20 V<br />
Maximum Rating: Forward Current: 25 mA
</p></blockquote>
<p>We assume the LED runs at 1.8 Volts with 5 mA. That looks reasonable when you take a look at other datasheets. Now, if we insert the 5 mA into the two figures above, we get: 2.5 Volt for the source pin and 0.15 V for the sink pin.</p>
<p><code><br />
2.5 V - 0.15 V = 2.35 V<br />
</code></p>
<p>So we get that 2.35 V is left for the LED. That is more than we have assumed (1.8 V). Higher voltage for the LED means more current. So this time we will compute with 10 mA. Inserting that again, we get 2.3 V for the source pin and 0.3 V for the sink pin.</p>
<p><code><br />
2.3 V - 0.3 V = 2.0 V<br />
</code></p>
<p>As you see, if the voltage over the LED rises, the current through it raises as well. But the rising current results in lower/higher output voltage from the source/sink pin. And that means lower current. It is, as if they are fighting each other. </p>
<p>2.0 V at 10 mA looks ok for the LED and the microcontroller.</p>
<p>That was one LED on two I/O pins. What, if we want to control a complete row of eight LEDs?</p>
<p>This time eight source pins, eight LEDs and one sink pin. From the example above, 10 mA per LED sums up to 80 mA (!). That&#8217;s a lot. Looking it up on the figure is not even possible. Lets assume, it all sums up to only 25 mA, that would be 3.125 mA per LED. That gives us 2.6 V at every source pin and 1.0 V for the single sink pin.</p>
<p><code><br />
2.6 V - 1.0 V = 1.6 V<br />
</code></p>
<p>That means, 1.6 V is left for every LED, we are a bit beneath the forward voltage of the LED. So the LED may be a bit dimmer. Again, if the LEDs would suck more current, the microcontroller would deliver less output voltage for the LEDs. </p>
<p>If you look thoroughly at the 64 pixels display, you may notice, that the rows with few pixels lit are a bit brighter than the others.</p>
<p>After all this computing and datasheet staring I think it is safe to let out the current limiting resistor in some cases. You have to take a closer look at specs to get an idea on how it will work out.</p>
<p>If I get something wrong or mixed things up, please feel free to comment on this.</p>
<h3>Links</h3>
<ul>
<li>Datasheet for <a href="http://www.atmel.com/dyn/resources/prod_documents/doc2543.pdf">Atmel ATtiny2313</a></li>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Light-emitting_diode">LED</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/tinkerlog/~4/wj1o1HrxEZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/04/05/driving-an-led-with-or-without-a-resistor/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
