<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4738310780774846631</id><updated>2012-02-28T18:10:46.011Z</updated><category term='Robots'/><category term='PING'/><category term='Arduino'/><category term='Motors'/><category term='MEGA'/><category term='Seeedstudio'/><category term='VNH5019'/><category term='LCD'/><category term='Ultrasonics'/><category term='Screwshield'/><category term='Sharp IR'/><category term='Pololu'/><category term='Batteries'/><title type='text'>CSlingsby</title><subtitle type='html'>A hobbyist playing with Robotics and Arduino</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-310951182709621710</id><published>2012-01-24T18:22:00.002Z</published><updated>2012-01-24T18:25:53.146Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ultrasonics'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><title type='text'>Scoutbot V0.1</title><content type='html'>Well everything is finally wired up and ready to rock and roll. 3 Ultrasonic sensors facing forward, left (45deg) and right (45deg) as well as a forward facing Sharp IR sensor and a rear IR sensor.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/Mj7qtnQYHhg/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Mj7qtnQYHhg?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" /&gt;&lt;param name="bgcolor" value="#FFFFFF" /&gt;&lt;embed width="320" height="266"  src="http://www.youtube.com/v/Mj7qtnQYHhg?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The first attempt at some collision code (shown below). It has some issues that need to be addressed but its a starting point. The code looks at the forward ultrasonic and if the value is less than 25cm it compares the left and right sensors for the best way to go. If the front ultrasonic sees a distance of 10cm the robot reverses.&lt;br /&gt;&lt;br /&gt;The value of 25cm may not be far enough based on the first fun, or I need to look a little into the breaking code for the motors. The robot can also get stuck in corners quite easily so that needs addressing. I also think the timing of values taken from the ultrasonics may need looking into, as the program goes through each one every loop, when there isn't a need.&lt;br /&gt;&lt;br /&gt;I've also started posting at&amp;nbsp;&lt;a href="http://letsmakerobots.com/node/30869" target="_blank"&gt;http://letsmakerobots.com&lt;/a&gt;&amp;nbsp;with a blog and design ideas&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: #ffffff; color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span style="color: dimgrey;"&gt;//--------------------------------------------------------- //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//                                                                                                         //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//Scoutbot V0.1                                                                                   //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//                                                                                                        //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//Programmed by Chris83 2012                                                         //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//                                                                                                       //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Featuring code snippets from Arduino PING Tutorial                      //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// IR Code with help from &lt;/span&gt;&lt;span style="color: #5555dd;"&gt;www.luckylarry.co.uk&lt;/span&gt;&lt;span style="color: dimgrey;"&gt;                                //&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------------------//&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Includes : Include all header files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #004a43;"&gt;#&lt;/span&gt;&lt;span style="color: #004a43;"&gt;include &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #40015a;"&gt;DualVNH5019MotorShield.h&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Constants : Declare all constants&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//Ultrasonics Pin Numbers&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ultra_cen    &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;53&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ultra_right  &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;51&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ultra_left   &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;49&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//IR Pin Numbers&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ir_front     &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;15&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ir_back       &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;14&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//Anaolgue Resolution&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;float&lt;/span&gt; analogue_5v &lt;span style="color: #808030;"&gt;=&lt;/span&gt;  &lt;span style="color: green;"&gt;0.0048828125&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// (5V / 1024)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;float&lt;/span&gt; analogue_3v &lt;span style="color: #808030;"&gt;=&lt;/span&gt;  &lt;span style="color: green;"&gt;0.0032226563&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// (3.3V / 1024)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Variables : Declare all global variables&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Setup The motor shield with declaration md&lt;/span&gt;&lt;br /&gt;DualVNH5019MotorShield md&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//Ultrasonic distance variables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; center_dist&lt;span style="color: #808030;"&gt;,&lt;/span&gt; right_dist&lt;span style="color: #808030;"&gt;,&lt;/span&gt; left_dist&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//IR distance variables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; IR_front_dist&lt;span style="color: #808030;"&gt;,&lt;/span&gt; IR_back_dist&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Functions : Declare all Functions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;float&lt;/span&gt; get_distance_IR&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; IR_Pin&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;float&lt;/span&gt; volts &lt;span style="color: #808030;"&gt;=&lt;/span&gt; analogRead&lt;span style="color: #808030;"&gt;(&lt;/span&gt;IR_Pin&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: #808030;"&gt;*&lt;/span&gt; analogue_5v&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;float&lt;/span&gt; distance &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;27&lt;/span&gt;&lt;span style="color: #808030;"&gt;*&lt;/span&gt;&lt;span style="color: #603000;"&gt;pow&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;volts&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: green;"&gt;1.10&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;return&lt;/span&gt; distance &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; get_distance_ultra&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; ultra_Pin&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// Local Variables for get_distance&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; duration&lt;span style="color: #808030;"&gt;,&lt;/span&gt; distance&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;br /&gt;  &lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// Sensor Pre-set . Set pin LOW first for a clean signal. Then High to activate Ultrasonic senor&lt;/span&gt;&lt;br /&gt;  pinMode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; OUTPUT&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; LOW&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  delayMicroseconds&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; HIGH&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  delayMicroseconds&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;5&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; LOW&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// Sensor Center Detect&lt;/span&gt;&lt;br /&gt;  pinMode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; INPUT&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  duration &lt;span style="color: #808030;"&gt;=&lt;/span&gt; pulseIn&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_Pin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; HIGH&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;//Convert Duration to CM&lt;/span&gt;&lt;br /&gt;  distance &lt;span style="color: #808030;"&gt;=&lt;/span&gt; microsecondsToCentimeters&lt;span style="color: #808030;"&gt;(&lt;/span&gt;duration&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color: dimgrey;"&gt;//Return distance in CM&lt;/span&gt;&lt;br /&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;return&lt;/span&gt; distance&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; microsecondsToCentimeters&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; microseconds&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: dimgrey;"&gt;// The speed of sound is 340 m/s or 29 microseconds per centimeter.&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// The ping travels out and back, so to find the distance of the&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// object we take half of the distance travelled.&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;return&lt;/span&gt; microseconds &lt;span style="color: #808030;"&gt;/&lt;/span&gt; &lt;span style="color: #008c00;"&gt;29&lt;/span&gt; &lt;span style="color: #808030;"&gt;/&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt; &lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Setup: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; setup&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;begin&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9600&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;init&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Init the Motor Shield md&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;//---------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// Main:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; loop&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt; center_dist &lt;span style="color: #808030;"&gt;=&lt;/span&gt; get_distance_ultra&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_cen&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; right_dist  &lt;span style="color: #808030;"&gt;=&lt;/span&gt; get_distance_ultra&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_right&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; left_dist   &lt;span style="color: #808030;"&gt;=&lt;/span&gt; get_distance_ultra&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ultra_left&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; IR_front_dist &lt;span style="color: #808030;"&gt;=&lt;/span&gt; get_distance_IR&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ir_front&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; IR_back_dist &lt;span style="color: #808030;"&gt;=&lt;/span&gt; get_distance_IR&lt;span style="color: #808030;"&gt;(&lt;/span&gt;ir_back&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;      &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;Center: &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;center_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;Left: &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;left_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;Right: &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;right_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;IR Front: &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;IR_front_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;IR Back: &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;IR_back_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;center_dist &lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;25&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// If Center Ultrasonic sees a distance greater than 25cm go forward&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;      md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;90&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;90&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;br /&gt;   &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;center_dist &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #008c00;"&gt;25&lt;/span&gt; &lt;span style="color: #808030;"&gt;|&lt;/span&gt;&lt;span style="color: #808030;"&gt;|&lt;/span&gt; IR_front_dist &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #008c00;"&gt;25&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// If Center Ultrasonic sees a distance less than 25cm slow and compare&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;      md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;left_dist &lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; right_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Compare left and right ultrasonics. If Left is greater than right, GO LEFT&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Start motors going LEFT&lt;/span&gt;&lt;br /&gt;           delay &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Run motors for 1 sec left&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Stop motors&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;left_dist &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt; right_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Compare left and right ultrasonics. If Left is less than right, GO RIGHT&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Start motors going RIGHT&lt;/span&gt;&lt;br /&gt;           delay &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Run motors for 1 sec left&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Stop motors&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: purple;"&gt;}&lt;/span&gt;      &lt;br /&gt;   &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;center_dist &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #008c00;"&gt;10&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// If Center Ultrasonic sees a distance less than 10cm STOP!&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;     md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// STOP!&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;     &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;IR_back_dist &lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #008c00;"&gt;25&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// If Room to reverse ( greater than 25cm )&lt;/span&gt;&lt;br /&gt;     &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;       md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;90&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;90&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Go backwards&lt;/span&gt;&lt;br /&gt;      delay &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;//Run Motors for 1 second &lt;/span&gt;&lt;br /&gt;      md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;     &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;left_dist &lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; right_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Compare left and right ultrasonics. If Left is greater than right, GO LEFT&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Start motors going LEFT&lt;/span&gt;&lt;br /&gt;           delay &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Run motors for 1 sec left&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Stop motors&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: maroon; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;left_dist &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt; right_dist&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Compare left and right ultrasonics. If Left is less than right, GO RIGHT&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Start motors going RIGHT&lt;/span&gt;&lt;br /&gt;           delay &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Run motors for 1 sec left&lt;/span&gt;&lt;br /&gt;           md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: dimgrey;"&gt;// Stop motors&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt; delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;  &lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-310951182709621710?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/310951182709621710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2012/01/scoutbot-v01.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/310951182709621710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/310951182709621710'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2012/01/scoutbot-v01.html' title='Scoutbot V0.1'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-847144964093114944</id><published>2012-01-15T17:28:00.001Z</published><updated>2012-01-16T17:14:16.820Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Screwshield'/><category scheme='http://www.blogger.com/atom/ns#' term='Ultrasonics'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharp IR'/><category scheme='http://www.blogger.com/atom/ns#' term='MEGA'/><title type='text'>Not enough space</title><content type='html'>Sensor wires are small. So small in fact that screw terminals sometimes can't grip them properly and the available pin crimps that I had just wouldn't crimp correctly. I needed some kind of breakout board for them to attach to the Mega screwshield.&lt;br /&gt;&lt;br /&gt;In addition to this there wasn't any space left on the Wild Thumper to mount anything without building a 2nd level. A re-design was needed.....&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0214.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0214.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0220.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0220.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Instead of using an ABS box for a mounting point, I just used spare strip board. This enabled me to build in a separate breakout board for the sensors with screw terminals to wire into the screwshield.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0221.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.cslingsby.co.uk/public/photos/IMG_0221.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The ultrasonic sensors are wired GND / VCC / SIG which is the centre board with 9 headers for further expansion. The Sharp IR sensor however is wired VCC / GND / ANALOGUE, so a smaller board in the top right of this picture was made. Each board gets a 5V and a GND signal thats common to all header connections. The Signal pins are then all wired upto a screw terminal to allow an easy link across to the screw shield.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-847144964093114944?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/847144964093114944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2012/01/not-enough-space.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/847144964093114944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/847144964093114944'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2012/01/not-enough-space.html' title='Not enough space'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-8515798606143082427</id><published>2012-01-13T15:06:00.001Z</published><updated>2012-01-15T17:14:07.521Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VNH5019'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><category scheme='http://www.blogger.com/atom/ns#' term='MEGA'/><title type='text'>Not enough pins! (MEGA Screwshield)</title><content type='html'>After connecting up the ultrasonics and IR sensors to the board I started looking into how many I/O pins I had left on the Arduino&amp;nbsp;Duemilanove board. The VNH 5019 Motor shield requires 8 digitals and 2 analogue pins. This left 6 digital pins and 4 analogues, of which 3 ultrasonics needed 3 digital pins and the IR sensor an analogue, not much room for expansion!&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0201.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0201.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Something bigger and better was needed....the MEGA :) 54 digital pins and 16 analogues should allow plenty of expansion!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;While playing about with the motors I realised that just pushing wires into the Arduino headers wasn't a great solution, any slight knock/bump and they'd fall out. While Screw Shields are common for the standard Arduino's I couldn't find one on the market for the Mega.&lt;br /&gt;&lt;br /&gt;Setting about designing one I realised a small design issue with all Arduino's. The digital pin headers between Digital 10/9/8 and the next header 7/6/5/.. is a distance thats not a standard strip board pinout. All the other headers line up with a strip board apart from these two.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0206.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://www.cslingsby.co.uk/public/photos/IMG_0206.jpg" width="300" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;As I was planning on still using other shields, I just cut a section out. I didn't bother with bringing VCC and RESET pins into screw headers and originally planned to duplicate the 5v / 3V / GND pins on both sides of the shield however couldn't think of a tidy way of doing it. Not all pins are taken to screw terminals but this should give me enough I/O (famous last words!).&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0210.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0210.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As I wanted to bring some analogues out to screw headers I kind of lost the space needed to bring both rows of digitals out.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0213.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0213.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;All mounted, just needing the sensors wiring in then I can finally start programming something useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-8515798606143082427?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/8515798606143082427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2012/01/not-enough-pins.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/8515798606143082427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/8515798606143082427'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2012/01/not-enough-pins.html' title='Not enough pins! (MEGA Screwshield)'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-2585215754791321724</id><published>2012-01-03T16:22:00.003Z</published><updated>2012-01-15T16:43:40.301Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ultrasonics'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharp IR'/><title type='text'>Sensors!</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0088.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.cslingsby.co.uk/public/photos/IMG_0088.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;While thinking about how to mount my ultrasonic transducer onto the chassis I started thinking about other sensors that I would like to use and an actual purpose for the robot. To start with I wanted the robot just to be able to do basic collision avoidance. As such would a single ultrasonic sensor be enough? Should I mount it to a servo motor so it could pan, or should I buy a number of the sensors? Would I just want ultrasonics or should I investigate IR (Infra red) as well.&lt;br /&gt;&lt;br /&gt;I decided as the Seeedstudio sensors were relatively cheap I'd buy a few more along with a Sharp IR sensor. I also needed some kind of mounting bracket.&amp;nbsp;&lt;a href="http://www.active-robots.com/" target="_blank"&gt;Active Robots&lt;/a&gt;&amp;nbsp;had a range of brackets, but as with most things on the internet I had no idea what they would actually be like once I received them. I decided on sampling a few types.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Lynxmotion MPSH-01 Multi-purpose Bracket&lt;/li&gt;&lt;li&gt;Active Robots UB1S3 Bracket (All Sharp IR and Devantech Ultrasonics)&lt;/li&gt;&lt;li&gt;Active Robots SPB1S3 Panning Bracket&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;The Sharp GP2Y0A21YK IR sensor mounted perfectly on the UB1S3 bracket as advertised, however the Seeedstuido Ultrasonic module was a close fit to the panning bracket but not a perfect fit (Nothing a needle file couldn't handle).&amp;nbsp;&lt;/div&gt;&lt;h1 class="productGeneral" id="productName" style="color: #9a9a9a; font-family: verdana, arial, helvetica, sans-serif; font-size: 1.5em; margin-bottom: 0.3em; margin-left: 0px; margin-right: 0px; margin-top: 0.3em;"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/h1&gt;&lt;div&gt;In the end I mashed all the brackets into one to provide a suitable mounting point for 3 x Ultrasonic sensors angled 45 degrees apart and a forward facing IR sensor.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0090.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.cslingsby.co.uk/public/photos/IMG_0090.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I knocked up a quick breakout board to enable the sensors to easily connect with the Arduino and test them all.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0096.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.cslingsby.co.uk/public/photos/IMG_0096.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-2585215754791321724?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/2585215754791321724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2012/01/sensors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/2585215754791321724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/2585215754791321724'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2012/01/sensors.html' title='Sensors!'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-7096301490157024902</id><published>2011-12-22T21:45:00.004Z</published><updated>2011-12-31T10:27:17.126Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VNH5019'/><category scheme='http://www.blogger.com/atom/ns#' term='Motors'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Batteries'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><title type='text'>Motor Tests</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0071.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://www.cslingsby.co.uk/public/photos/IMG_0071.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Finally I have power and a robot chassis so time to start work on putting everything together and testing it!&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The robot is powered by a 7.2V NiMh 4300mAH battery, this is connected to a Dagu High Power&amp;nbsp;&lt;a href="http://letsmakerobots.com/node/26537" style="color: #8c8c8c; text-decoration: underline;" title=""&gt;switch&lt;/a&gt;. This switch allows a manual on/off or one to be fed from some other electrical source, either a switch mounted elsewhere or from a microprocessor controller. The switch is then wired into the VNH5019 motor shield. This in turn powers the Arduino and gives power to the motors.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0062.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://www.cslingsby.co.uk/public/photos/IMG_0062.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The VNH5019 comes with a pre written Arduino library so its pretty easy to get started. I loaded up the example program, downloaded to the Arduino and I had 4 motors powering up and down. One thing quickly became apparent, at full power this robot is too fast, so I edited the code to slow it down. Now I did this after about 10 seconds of first powering up, and it lead me on a 4 hour wild goose chase.&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The VNH5019 code allows the motors to be peered from -400 (full power reverse) to +400 (full powered forward). At +/- 400 it was simply too fast so I changed the code to +/- 100. On doing so I began to notice that intermittently 1 or 2 of the motors would fail to power up. It would consistently be the same 2, 1 more than the other. Had I been sent some faulty motors? I stripped out all the powering wiring and re did everything. Still the same fault. I then disconnected each motor and tested it independently. Each seemed fine, it was only when they were all connected. I began testing voltages and the penny dropped. At +/- 100 The VNH5019 was only giving out 1.62V. The motors are rated 2v-7v. There simply wasn't enough power to drive each channel of 2 motors. On modifying the program to +/- 200 the problem disappeared. Voltage readings at this setting are approx. 3.2V.&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Below is the code used to test the motors. It starts both sets of motors driving forward at half speed (200) for 2 seconds, then stops them, waits 5 seconds and does the same in the backwards direction. To turn the chassis, motors on the A channel should run one way and the motors on the B channel should run opposite ( e.g.md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds&amp;nbsp;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&amp;nbsp;).&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;pre style="background: #ffffff; color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span style="color: #004a43;"&gt;#&lt;/span&gt;&lt;span style="color: #004a43;"&gt;include &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #40015a;"&gt;DualVNH5019MotorShield.h&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;DualVNH5019MotorShield md&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; setup&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="color: purple; font-size: x-small;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;begin&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;115200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;println&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;Dual VNH5019 Motor Shield&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;init&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="color: purple; font-size: x-small;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; loop&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="color: purple; font-size: x-small;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;2000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;5000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setSpeeds &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;2000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; md&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setBrakes &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;5000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-7096301490157024902?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/7096301490157024902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/motor-tests.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/7096301490157024902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/7096301490157024902'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/motor-tests.html' title='Motor Tests'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-8425436629383713126</id><published>2011-12-21T20:38:00.001Z</published><updated>2011-12-31T10:01:36.385Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Motors'/><category scheme='http://www.blogger.com/atom/ns#' term='Robots'/><category scheme='http://www.blogger.com/atom/ns#' term='Batteries'/><title type='text'>Batteries</title><content type='html'>&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Power requirements for this robot are going to be slightly more than a few AA's in a battery holder. The chassis can carry unto 2 sub C packs with are often found in RC cars. The Arduino requires an input between 7v and 12v as it has its own voltage regulation to 5v and 3.3v and the motors in the chassis required around 6v - 7v, so I decided on a 7.2v pack. The VNH5019 can power the Arduino however it features no regulation so the voltage input to it must be suitable for both the motors and Arduino, which 7.2v is.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;I naively plunged straight in and ordered some Lipo (Lithium Polymer) batteries as most robot websites seemed to stock them in their various forms. I picked out a 7.2v Sub C sized pack, and Lipo charger. However after placing the order I decided to look into the types of batteries a little more and found to my horror Lipo maybe wasn't the best choice. It seems they require a lot of care and attention with regards charging and discharging. Batteries had to be kept balanced and couldn't be fully discharged.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;After looking at various&amp;nbsp;&lt;a href="http://www.rcgroups.com/forums/showthread.php?t=599287" style="color: #8c8c8c; text-decoration: underline;" title="LIPO"&gt;forums&lt;/a&gt;&amp;nbsp;it became clear this was something that really should be used outside the home in a garage or workshop rather than a spare bedroom due to "abused batteries" potentially catching fire. Lots of sites recommended charging in flameproof bags or buckets of sand. Now a lot of this info was written when Lipo's first came out and I know things have probably moved on since then, but I really didn't want to risk it.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NiMh an older battery technology again used frequently in the RC arena looked like the better option. The major differences between NiMh and Lipo appeared to be capacity and weight. Lipo is lighter and the density is greater giving a larger Mah (milliamp hour) for the equivalent weight, however NiMh is a little more forgiving with the charging and discharging, and while caution should still be taken while charging (never left unattended) a bucket of sand wasn't a recommendation :).&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0056.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://www.cslingsby.co.uk/public/photos/IMG_0056.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Battery capacity wise I wasn't sure where to start and what I would need. The motors I was using had a no load current of 420mA X 4 ( approx 1700mA ) and approximating normal running with the chassis maybe double that. The Arduino and a few sensors I didn't think would be mush more than 3-400mA.&lt;/div&gt;&lt;ul style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 20px; margin-left: 30px; margin-right: 30px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;Motors approx 3000mA - 3500mA&lt;/li&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Arduino approx 400mA&lt;/div&gt;&lt;/li&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Total around 4000mA.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;I therefore chose a 4300mAH battery to hopefully give me an hour or so between charges.&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Now to fire it all up and see how it runs :)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-8425436629383713126?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/8425436629383713126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/batteries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/8425436629383713126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/8425436629383713126'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/batteries.html' title='Batteries'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-3847308857060199246</id><published>2011-12-17T19:51:00.001Z</published><updated>2011-12-31T09:57:51.825Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='VNH5019'/><category scheme='http://www.blogger.com/atom/ns#' term='Motors'/><category scheme='http://www.blogger.com/atom/ns#' term='Pololu'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><title type='text'>Robots! Part 2</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0054.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0054.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Well it finally arrived, thanks to&amp;nbsp;&lt;a href="http://robosavvy.com/" style="color: #8c8c8c; text-decoration: underline;" title="Robosavvy"&gt;Robosavvy&lt;/a&gt;&amp;nbsp;and the Royal Mail :). The kit comes with the main chassis already built along with the motors and suspension system. All that I had to do was fit the motor axial mounts and the wheels. I left the 2DOF arm off for now, mainly as the chassis is a little bigger than expected and it may have trouble moving around with the arm on. This kit has the 75:1 motor gear boxes and the specification sheets says it will do upto 3km/h. This chassis also has the option of the 34:1 gearbox that will do 7km/h which is a little fast for indoors! Perfect for an outside robot though.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The motors with the Wild Thumper are also quite beefy. Rated at 6VDC (usable between 2VDC and 7.5VDC) with a stall current around 6amps, the Arduino is not going to be able to drive these directly.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Once I started looking around at the various motor shields for the Arduino, one thing quickly became apparent. Motors upto 2A were fine but anything above this was going to require a special motor driver board. The problem was also compounded by the fact the Wild Thumper's motors where connected together in pairs (Both right side act as one, as do the left side). This meant a potential 12amps should the motors stall, on the plus side I could get by with a single or dual motor board.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;a href="http://www.pololu.com/" style="color: #8c8c8c; text-decoration: underline;" title="Pololu"&gt;Pololu&lt;/a&gt;&amp;nbsp;seemed to offer a wide variety of motor control boards and after looking around I found the&amp;nbsp;&lt;a href="http://www.pololu.com/catalog/product/2502" style="color: #8c8c8c; text-decoration: underline;" title="VNH5019"&gt;VNH5019&lt;/a&gt;&amp;nbsp;which would control both motors and was an Arduino shield, BONUS! As it was a dual motor driver it also worked out cheaper than buying 2 separate boards. In addition to this Pololu have also written an Arduino library to use with the shield.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0058.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.cslingsby.co.uk/public/photos/IMG_0058.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The board comes in kit form, where you have to solder the headers and connection block on, but all the other SMD chips are already attached.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0060.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://www.cslingsby.co.uk/public/photos/IMG_0060.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The VNH5019 requires external power between 5v and 24v and there is an option to power the Arduino board through the VNH5019 meaning only 1 power supply is required. This is controlled through the blue jumper in the pictures. Jumper present means the Arduino is powered through the VNH5019. When it is configured this way the Arduino can be programmed via USB however NO OTHER POWER can be connected as it will damage both boards. Without the jumper present he Arduino will need its own power source.&lt;/div&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Now off to go and look at how to power it all!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-3847308857060199246?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/3847308857060199246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/robots-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/3847308857060199246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/3847308857060199246'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/robots-part-2.html' title='Robots! Part 2'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-159795258704778445</id><published>2011-12-14T15:24:00.001Z</published><updated>2011-12-31T09:52:28.393Z</updated><title type='text'>Robots!</title><content type='html'>&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;So after playing about with the Arduino for a few weeks now, doing things like ultrasonic rangefinders, temperature monitors I decided to start looking for robot chassis. Not having access to a workshop, only a desk I knew I was going for a robot kit in some way, shape or form be it one that was pre assembled or one that required some assembly but could be done using only a few simple tools ( no machining required! ).&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;There are various online stores for robotic parts selling kits, however I found there were basic kits that didn't look like they'd last me long and left little room for customisation to products that were just chassis costing hundreds of pounds to full kits costing thousands!. What I wanted was something that allowed me to customise how I wanted, something that would last both in terms of durability and as the project grows and potentially something that could take a knock or two.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Some of the various models I considered.&lt;/div&gt;&lt;ul style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 20px; margin-left: 30px; margin-right: 30px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;a href="http://www.robotshop.com/eu/dfrobotshop-rover-tracked-robot-basic-kit.html" style="color: #8c8c8c; text-decoration: underline;" title="DFRobot Tracked Kit"&gt;DFRobot Tracked kit&lt;/a&gt;&amp;nbsp;- with a review from&amp;nbsp;&lt;a href="http://www.rugcommunity.org/page/dfrobotshop-rover-arduino" style="color: #8c8c8c; text-decoration: underline;" title="RUGcommunity Review"&gt;RUG Community&lt;/a&gt;. This kit seemed to contain just about everything I'd need however it just didn't look durable enough. It also seemed to lack many expansion options. It may be been able to carry a sensor or to but nothing much. It also contained a customised Arduino board that I already had. On the plus side quite cheap :).&lt;/div&gt;&lt;/li&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;a href="http://www.robotshop.com/eu/dfrobot-4wd-arduino-platform-encoders-2.html" style="color: #8c8c8c; text-decoration: underline;" title="DFRobot 4WD Kit"&gt;DFRobot 4WD&lt;/a&gt;&amp;nbsp;- with a review from&amp;nbsp;&lt;a href="http://www.rugcommunity.org/page/dfrobot-4wd-arduino-mobile" style="color: #8c8c8c; text-decoration: underline;" title="RUG Review"&gt;RUG Community&lt;/a&gt;. This kit seemed a great kit to start with with quite a lot of expansion options should I need them. The only thing that put me off this kit was the fact the motors didn't seem too powerful and could be hard to replace if the need arose.&lt;/div&gt;&lt;/li&gt;&lt;li style="line-height: 1.8em; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div style="line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;a href="http://robosavvy.com/store/product_info.php/products_id/1176?osCsid=4f3d34bb2480cb3dbecdb0a91b6f9656" style="color: #8c8c8c; text-decoration: underline;" title="Wild Thumper"&gt;Dagu Wild Thumper 4WD&lt;/a&gt;&amp;nbsp;- with a review from&amp;nbsp;&lt;a href="http://www.rugcommunity.org/page/dagu-wild-thumper-6wd-all" style="color: #8c8c8c; text-decoration: underline;" title="RUGComminity"&gt;RUG Community&lt;/a&gt;. The review from RUG was for the 6WD version but Dagu also do the smaller 4WD. This platform appears to have the power, expandability and the robustness required.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;I did look at various models from Lynxmotion however they seemed to be just a little too pricey for what I required. In the end I went for the Dagu 4WD Wild Thumper, with the 2DOF arm pack. All ordered and should be here in a few days (depending on how bad the Christmas post is already :) )&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-159795258704778445?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/159795258704778445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/robots.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/159795258704778445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/159795258704778445'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/robots.html' title='Robots!'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-5046167659642207044</id><published>2011-12-12T12:56:00.003Z</published><updated>2011-12-31T09:47:43.936Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ultrasonics'/><category scheme='http://www.blogger.com/atom/ns#' term='LCD'/><category scheme='http://www.blogger.com/atom/ns#' term='PING'/><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><category scheme='http://www.blogger.com/atom/ns#' term='Seeedstudio'/><title type='text'>Ultrasonics</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.cslingsby.co.uk/public/photos/IMG_0073.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.cslingsby.co.uk/public/photos/IMG_0073.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;As the final goal is a robot, collision detection is a must. There are various types of detection from IR (Infra-red) range finding, ultrasonic, laser and actual collision detection through use of a push button of something similar. For the purposes of this post I'll be documenting my findings with ultrasonics, however I do intend to look into IR and maybe even laser at some point.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;There are many ultrasonic modules on the market, ranging from £10 - £100+. Interfaces range from TTL, I2C and Serial. However by far the easiest to interface with Arduino is the PING sensor. The PING sensor itself is relatively cheap and accurate enough for a basic collision avoidance robot, however SeeedStudio do an even cheaper model (about 2/3 the price of the PING). This is a simple 3 wire sensor, 5V, GND and SNG (which can be connected to any digital pin on the Arduino).&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Using the&amp;nbsp;&lt;a href="http://www.arduino.cc/en/Tutorial/Ping"&gt;PING&lt;/a&gt;&amp;nbsp;tutorial and the inbuilt&amp;nbsp;&lt;a href="http://arduino.cc/en/Tutorial/LiquidCrystal"&gt;LCD&lt;/a&gt;&amp;nbsp;library that comes with the Arduino IDE, I created a quick demo. All wiring drawings can be found in the respective tutorials.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/Af-qF9X4xHU/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Af-qF9X4xHU?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" /&gt;&lt;param name="bgcolor" value="#FFFFFF" /&gt;&lt;embed width="320" height="266"  src="http://www.youtube.com/v/Af-qF9X4xHU?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The sensor basically works by sending a High pulse on the digital pin for 2ms, then recording the time taken (in microseconds) for the same pin the receive the pulse back. The time taken, divided by 2 can then be used to calculate the distance. The PING documentation states that sound travels at 340 m/s in air or 29 microseconds / cm.&lt;/div&gt;&lt;div style="color: #6b6b6b; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The sensor was pretty accurate, easily to within 1cm using my crude measuring techniques in the video.&lt;/div&gt;&lt;div style="color: #6b6b6b; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Below is the code used in the demo:&lt;/div&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: dimgrey;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span style="color: dimgrey;"&gt;/* Ping))) Sensor&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;This sketch reads a PING))) ultrasonic rangefinder and returns the&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;distance to the closest object in range. To do this, it sends a pulse&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;to the sensor to initiate a reading, then listens for a pulse &lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;to return.  The length of the returning pulse is proportional to &lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;the distance of the object from the sensor.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The circuit:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* +V connection of the PING))) attached to +5V&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* GND connection of the PING))) attached to ground&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* SIG connection of the PING))) attached to digital pin 7&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #5555dd;"&gt;http://www.arduino.cc/en/Tutorial/Ping&lt;/span&gt;&lt;span style="color: dimgrey;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;created 3 Nov 2008&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;by David A. Mellis&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;modified 30 Aug 2011&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;by Tom Igoe&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;This example code is in the public domain.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #004a43;"&gt;#&lt;/span&gt;&lt;span style="color: #004a43;"&gt;include &lt;/span&gt;&lt;span style="color: maroon;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #40015a;"&gt;LiquidCrystal.h&lt;/span&gt;&lt;span style="color: maroon;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: dimgrey;"&gt;// initialize the library with the numbers of the interface pins&lt;/span&gt;&lt;br /&gt;LiquidCrystal lcd&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;12&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;11&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;5&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;4&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;3&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;const&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;int&lt;/span&gt; pingPin &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;7&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; setup&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;begin&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;16&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  Serial&lt;span style="color: #808030;"&gt;.&lt;/span&gt;begin&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9600&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;void&lt;/span&gt; loop&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// establish variables for duration of the ping, &lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// and the distance result in inches and centimeters:&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; duration&lt;span style="color: #808030;"&gt;,&lt;/span&gt; cm&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&lt;/span&gt;&lt;br /&gt;  pinMode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; OUTPUT&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; LOW&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  delayMicroseconds&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; HIGH&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  delayMicroseconds&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;5&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  digitalWrite&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; LOW&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// The same pin is used to read the signal from the PING))): a HIGH&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// pulse whose duration is the time (in microseconds) from the sending&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// of the ping to the reception of its echo off of an object.&lt;/span&gt;&lt;br /&gt;  pinMode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; INPUT&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  duration &lt;span style="color: #808030;"&gt;=&lt;/span&gt; pulseIn&lt;span style="color: #808030;"&gt;(&lt;/span&gt;pingPin&lt;span style="color: #808030;"&gt;,&lt;/span&gt; HIGH&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// convert the time into a distance&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  cm &lt;span style="color: #808030;"&gt;=&lt;/span&gt; microsecondsToCentimeters&lt;span style="color: #808030;"&gt;(&lt;/span&gt;duration&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setCursor&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #0000e6;"&gt;Range in cm:&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setCursor&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;print&lt;span style="color: #808030;"&gt;(&lt;/span&gt;cm&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  delay&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1000&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;  lcd&lt;span style="color: #808030;"&gt;.&lt;/span&gt;clear&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; microsecondsToCentimeters&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;long&lt;/span&gt; microseconds&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// The speed of sound is 340 m/s or 29 microseconds per centimeter.&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// The ping travels out and back, so to find the distance of the&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: dimgrey;"&gt;// object we take half of the distance travelled.&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: maroon; font-weight: bold;"&gt;return&lt;/span&gt; microseconds &lt;span style="color: #808030;"&gt;/&lt;/span&gt; &lt;span style="color: #008c00;"&gt;29&lt;/span&gt; &lt;span style="color: #808030;"&gt;/&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: 1.1em;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-5046167659642207044?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/5046167659642207044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/ultrasonics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/5046167659642207044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/5046167659642207044'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/ultrasonics.html' title='Ultrasonics'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4738310780774846631.post-4639764067837422489</id><published>2011-12-05T09:25:00.000Z</published><updated>2011-12-31T09:53:12.623Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arduino'/><title type='text'>What is Arduino?</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://cslingsby.co.uk/public/photos/IMG_0030.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://cslingsby.co.uk/public/photos/IMG_0030.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Its an open source (Cheap!) micro controller, developed to be easy to use and flexible. As its open source anyone can build a board and market it. Popular board makers include official Arduino boards, DFRobot and Seeedstudio. It comes in multiple forms from the&amp;nbsp;&lt;a href="http://arduino.cc/en/Main/ArduinoBoardNano" target="_blank"&gt;Nano&lt;/a&gt;&amp;nbsp;with 14 digital and 8 analog pins to the&amp;nbsp;&lt;a href="http://arduino.cc/en/Main/ArduinoBoardMega2560" target="_blank"&gt;Mega&lt;/a&gt;&amp;nbsp;with 54 digital and 16 analog pins. The Arduino can be programmed using open source software provided by Arduino on Windows, Linux and Mac platforms.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Code is written in Sketches, and quite closely resemble the C programming language syntax and keywords.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;I've tried other micro controller systems however as I'm developing on a Mac, and Arduino has a huge support community, I think its the better choice than say PICAXE or BASIC Stamp. Most Arduino boards accept a USB connection and can be programmed this way.&lt;/div&gt;&lt;div style="color: #6b6b6b; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5em; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The board I'll be using is the Duemilanove which features 14 digital pins and 6 analog pins. This should be enough for most basic projects and perhaps my first robot :)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4738310780774846631-4639764067837422489?l=cslingsby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cslingsby.blogspot.com/feeds/4639764067837422489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cslingsby.blogspot.com/2011/12/what-is-arduino.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/4639764067837422489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4738310780774846631/posts/default/4639764067837422489'/><link rel='alternate' type='text/html' href='http://cslingsby.blogspot.com/2011/12/what-is-arduino.html' title='What is Arduino?'/><author><name>Chris</name><uri>http://www.blogger.com/profile/13153793692190708966</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
