<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ArduinoFun.com Blog &#187; Robot</title>
	<atom:link href="http://arduinofun.com/blog/index.php/tag/robot/feed/" rel="self" type="application/rss+xml" />
	<link>http://arduinofun.com/blog</link>
	<description>- Think It - Build It - Share It -</description>
	<lastBuildDate>Thu, 01 Apr 2010 22:39:59 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Arduino Autonomous Robot</title>
		<link>http://arduinofun.com/blog/2009/11/25/arduino-autonomous-robot/</link>
		<comments>http://arduinofun.com/blog/2009/11/25/arduino-autonomous-robot/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 20:59:10 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Project Files]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Arduino Code]]></category>
		<category><![CDATA[Arduino Robot]]></category>
		<category><![CDATA[Arduino Sketch]]></category>
		<category><![CDATA[Autonomous Robot]]></category>
		<category><![CDATA[IR Sensor]]></category>
		<category><![CDATA[Parallax Ping Sonar]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[Sensor]]></category>
		<category><![CDATA[Sharp Sensor]]></category>

		<guid isPermaLink="false">http://arduinofun.com/blog/?p=275</guid>
		<description><![CDATA[This is a repost of a previous project. I am still working to get the older post back online from when we upgraded Wordpress.
The robot was basically built using a Parallax Boe Bot chassis. Rather than using the Basic Stamp we added an Arduino with a proto shield to control the robot functions.
You can use [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="320" height="240" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/6J_eh1HPu54" /><param name="align" value="left" /><param name="vspace" value="5" /><param name="hspace" value="5" /><embed type="application/x-shockwave-flash" width="320" height="240" src="http://www.youtube.com/v/6J_eh1HPu54" hspace="5" vspace="5" align="left"></embed></object>This is a repost of a previous project. I am still working to get the older post back online from when we upgraded Wordpress.</p>
<p>The robot was basically built using a Parallax Boe Bot chassis. Rather than using the Basic Stamp we added an <a href="http://store.arduinofun.com/freeduino-usb-complete-kit-arduino-duemilanove-compatible.html">Arduino</a> with a <a href="http://store.arduinofun.com/freeduino-protoshield-kit-for-arduino.html">proto shield</a> to control the robot functions.</p>
<p>You can use any type of chassis for this project. The robot moves about using a ping sonar and <a href="http://store.arduinofun.com/infrared-proximity-sensor--sharp-gp2y0a2021.html">IR sensors</a> to avoid running into any objects. As you can see in the video, it was a bit thrown off by our kitten. We added additional items such as a wireless camera that sends audio/video back to our TV.<span id="more-275"></span>The original design for this was created by an Instructable&#8217;s member and can be <a href="http://www.instructables.com/id/BOB-V20/">found here</a>.</p>
<p><strong>Items you will need for this project:</strong></p>
<ul>
<li><a href="http://store.arduinofun.com/freeduino-usb-complete-kit-arduino-duemilanove-compatible.html">Arduino/Freeduino</a> or <a href="http://store.arduinofun.com/breadboard-arduino-kit.html">Breadboard Arduino</a></li>
<li>(3) <a href="http://store.arduinofun.com/infrared-sensor-jumper-wire--3pin-js3.html">3-Wire Sensor Cables</a></li>
<li><a href="http://store.arduinofun.com/breadboard-400-tie-po400.html">Breadboard</a> (small) or <a href="http://store.arduinofun.com/breadboard-840-tie-po840.html">Breadboard</a> (large)</li>
<li><a href="http://store.arduinofun.com/freeduino-protoshield-kit-for-arduino.html">Protoshield</a></li>
<li>(3) <a href="http://store.arduinofun.com/infrared-proximity-sensor--sharp-gp2y0a2021.html">Sharp IR Sensors</a></li>
<li><a href="http://store.arduinofun.com/5v-1a-switching-voltage-regulat51.html">5V 1A Switching voltage regulator</a></li>
<li><a href="http://store.arduinofun.com/wire-jumper-kit-for-breadboards.html">Various lengths of wire</a></li>
<li><a href="http://store.arduinofun.com/5mm-red-and-green-leds-pk-of510.html">LED</a></li>
<li><a href="http://store.arduinofun.com/220-ohm-resistor-pk-22010.html">220 Ohm resistor</a></li>
<li><a href="http://store.arduinofun.com/4-aa-battery-holde4.html">Optional &#8211; 4 AA Battery Holder</a></li>
<li>Piezo Speaker/Element</li>
<li>Parallax Ping))) Ultrasonic Rangefinder</li>
<li>(2) Parallax Continuous Rotation Servos</li>
<li>1 Parallax Standard Rotation Servos</li>
<li>9.6V Ni-Cd Rechargeable Battery (or any other 8-AA cell <a href="http://store.arduinofun.com/4-aa-battery-holde4.html">battery     pack</a>/any rechargeable battery pack above 9V)</li>
<li>Optional Method: <a href="http://store.arduinofun.com/dual-motor-breakout-board.html">Dual Motor Breakout</a> and <a href="http://store.arduinofun.com/12vdc-mabuchi-rs380ph-12380.html">2 DC Motors</a> (<a href="http://arduinofun.com/blog/2009/10/25/duel-motor-driver/">Tutorial Available Here</a>)</li>
</ul>
<div id="attachment_310" class="wp-caption alignleft" style="width: 330px"><a href="http://www.flickr.com/photos/34908673@N00/4133522899/sizes/l/"><img class="size-full wp-image-310" title="Arduino Autonomous Robot" src="http://arduinofun.com/blog/wp-content/uploads/2009/11/lars1.jpg" alt="Arduino Autonomous Robot" width="320" height="240" /></a><p class="wp-caption-text">Arduino Autonomous Robot</p></div>
<p>The standard servo will be used to mount the Ping Rangefinder. This will give you a back and forth sweep motion as the robot travels around. The two continuous rotation servos are used for the wheels. You do not need to use the Parallax brand of servos, other brands will work. You may have to adjust the PWM values in the source code to go with the servos you are using.</p>
<p>It is also possible to use <a href="http://store.arduinofun.com/motors.html">DC motors</a> and edit the code, which would be considerably cheaper. You could use a SN754410 Quad Half H-Bridge to drive two DC motors. <a href="http://arduinofun.com/blog/2009/10/25/duel-motor-driver/">Tutorial for how to do this is available here</a>.</p>
<p>The Arduino hook up is pretty simple. You will have the following:</p>
<ul>
<li>Pin (Analog) 0: Left Sensor</li>
<li>Pin (Analog) 1: Center Sensor</li>
<li>Pin (Analog) 2: Right Sensor</li>
<li>Pin 5: Pan Servo</li>
<li>Pin 6: Left Drive Servo</li>
<li>Pin 7: Ultrasonic Rangefinder ( &#8216;Ping)))&#8217; )</li>
<li>Pin 9: Right Drive Servo</li>
<li>Pin 11: Piezo Speaker</li>
</ul>
<div id="attachment_313" class="wp-caption alignleft" style="width: 330px"><a href="http://www.flickr.com/photos/34908673@N00/4133522649/sizes/l/"><img class="size-full wp-image-313" title="Shield Close-up" src="http://arduinofun.com/blog/wp-content/uploads/2009/11/lars2.jpg" alt="Shield Close-up" width="320" height="240" /></a><p class="wp-caption-text">Shield Close-up</p></div>
<p>Radioshack sells an RC car battery as well as connector repair kit. You can solder the repair kit connector onto the shield, and then be able to hook up your battery to power the servos with. You can use a separate <a href="http://store.arduinofun.com/4-aa-battery-holde4.html">battery holder</a> to power the Arduino.</p>
<p>Make all your connections onto <a href="http://store.arduinofun.com/freeduino-protoshield-kit-for-arduino.html">the shield</a>. This way everything can remain in place if you need to use your Arduino for something else and save you from needing to tear apart everything.</p>
<p>for power to the shield, you won&#8217;t need any extra filter capacitors since the <a href="http://store.arduinofun.com/5v-1a-switching-voltage-regulat51.html">5V switching  regulator</a> has them built in. We used a small project box to hold the battery in place, and was able to attach the wireless camera on top of it.</p>
<p>The Arduino and camera are power source 1, while the servos and sensors are power source 2 (the RC battery). A small piece of PVC pipe mounted onto a cable clip will help you to keep your wires all organized to a central point and be less likely to get caught or tangled up into something as the robot is moving around.</p>
<p><strong>Arduino Sketch</strong></p>
<pre><span style="color: #7E7E7E;">// Begin Robot Code</span>
<span style="color: #CC6600;">int</span> micVal;
<span style="color: #CC6600;">int</span> cdsVal;
<span style="color: #CC6600;">int</span> irLval;  <span style="color: #7E7E7E;">// Left IR</span>
<span style="color: #CC6600;">int</span> irCval;  <span style="color: #7E7E7E;">// Center IR</span>
<span style="color: #CC6600;">int</span> irRval;  <span style="color: #7E7E7E;">// Right IR</span>

<span style="color: #CC6600;">int</span> i;   <span style="color: #7E7E7E;">// Generic Counter</span>
<span style="color: #CC6600;">int</span> x;  <span style="color: #7E7E7E;">// Generic Counter</span>
<span style="color: #CC6600;">int</span> PLval;  <span style="color: #7E7E7E;">// Pulse Width for Left Servo</span>
<span style="color: #CC6600;">int</span> PRval;  <span style="color: #7E7E7E;">// Pulse Width for Right Servo</span>
<span style="color: #CC6600;">int</span> cntr;  <span style="color: #7E7E7E;">// Generic Counter Used for Determining amt. of Object Detections</span>
<span style="color: #CC6600;">int</span> counter; <span style="color: #7E7E7E;">// Generic Counter</span>
<span style="color: #CC6600;">int</span> clrpth;  <span style="color: #7E7E7E;">// amt. of Milliseconds Of Unobstructed Path</span>
<span style="color: #CC6600;">int</span> objdet;  <span style="color: #7E7E7E;">// Time an Object was Detected</span>
<span style="color: #CC6600;">int</span> task;  <span style="color: #7E7E7E;">// Routine to Follow for Clearest Path</span>
<span style="color: #CC6600;">int</span> pwm;  <span style="color: #7E7E7E;">// Pulse Width for Pan Servo</span>
<span style="color: #CC6600;">boolean</span> add;  <span style="color: #7E7E7E;">// Whether to Increment or Decrement PW Value for Pan Servo</span>
<span style="color: #CC6600;">int</span> distance;  <span style="color: #7E7E7E;">// Distance to Object Detected via Ultrasonic Ranger</span>
<span style="color: #CC6600;">int</span> oldDistance;  <span style="color: #7E7E7E;">// Previous Distance Value Read from Ultrasonic Ranger</span>

<span style="color: #CC6600;">float</span> scale = 1.9866666666666666666666666666667;  <span style="color: #7E7E7E;">// *Not Currently Used*</span>

<span style="color: #CC6600;">int</span> LeftPin = 6;  <span style="color: #7E7E7E;">// Left Servo</span>
<span style="color: #CC6600;">int</span> RightPin = 9;  <span style="color: #7E7E7E;">// Right Servo</span>
<span style="color: #CC6600;">int</span> PiezoPin = 11;  <span style="color: #7E7E7E;">// Piezo</span>
<span style="color: #CC6600;">int</span> PingServoPin = 5;  <span style="color: #7E7E7E;">// Pan Servo</span>
<span style="color: #CC6600;">int</span> irLPin = 0;            <span style="color: #7E7E7E;">// Analog 0; Left IR</span>
<span style="color: #CC6600;">int</span> irCPin = 1;            <span style="color: #7E7E7E;">// Analog 1; Center IR</span>
<span style="color: #CC6600;">int</span> irRPin = 2;            <span style="color: #7E7E7E;">// Analog 2; Right IR</span>

<span style="color: #CC6600;">int</span> ultraSoundSignal = 7; <span style="color: #7E7E7E;">// Ultrasound signal pin</span>
<span style="color: #CC6600;">int</span> val = 0;              <span style="color: #7E7E7E;">// Used for Ultrasonic Ranger</span>
<span style="color: #CC6600;">int</span> ultrasoundValue = 0;  <span style="color: #7E7E7E;">// Raw Distance Val</span>
<span style="color: #CC6600;">int</span> oldUltrasoundValue;  <span style="color: #7E7E7E;">// *Not used*</span>
<span style="color: #CC6600;">int</span> pulseCount;        <span style="color: #7E7E7E;">// Generic Counter</span>
<span style="color: #CC6600;">int</span> timecount = 0; <span style="color: #7E7E7E;">// Echo counter</span>
<span style="color: #CC6600;">int</span> ledPin = 13; <span style="color: #7E7E7E;">// LED connected to digital pin 13</span>

#define BAUD 9600
#define CmConstant 1/29.034

<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><strong>setup</strong></span>() {
  <span style="color: #CC6600;">Serial</span>.<span style="color: #CC6600;">begin</span>(9600);
  <span style="color: #CC6600;">pinMode</span>(PiezoPin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(ledPin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(LeftPin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(RightPin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(PingServoPin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(irLPin, <span style="color: #006699;">INPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(irCPin, <span style="color: #006699;">INPUT</span>);
  <span style="color: #CC6600;">pinMode</span>(irRPin, <span style="color: #006699;">INPUT</span>);
  <span style="color: #CC6600;">for</span>(i = 0; i &lt; 500; i++) {
    <span style="color: #CC6600;">digitalWrite</span>(PiezoPin, <span style="color: #006699;">HIGH</span>);
    <span style="color: #CC6600;">delayMicroseconds</span>(1000);
    <span style="color: #CC6600;">digitalWrite</span>(PiezoPin, <span style="color: #006699;">LOW</span>);
    <span style="color: #CC6600;">delayMicroseconds</span>(1000);
  }
  <span style="color: #CC6600;">for</span>(i = 0; i &lt; 20; i++) {
  <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">HIGH</span>);
  <span style="color: #CC6600;">delayMicroseconds</span>(655 * 2);
  <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">LOW</span>);
  <span style="color: #CC6600;">delay</span>(20);
  }
  ultrasoundValue = 600;
  i = 0;
}

<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><strong>loop</strong></span>()
{
  <span style="color: #7E7E7E;">//Scan();</span>
  Look();
  Go();
}
<span style="color: #CC6600;">void</span> Look() {
  irLval = <span style="color: #CC6600;">analogRead</span>(irLPin);
  irCval = <span style="color: #CC6600;">analogRead</span>(irCPin);
  irRval = <span style="color: #CC6600;">analogRead</span>(irRPin);
  <span style="color: #7E7E7E;">//if(counter &gt; 10) {</span>
    <span style="color: #7E7E7E;">//counter = 0;</span>
    <span style="color: #7E7E7E;">//readPing();</span>
  <span style="color: #7E7E7E;">//}</span>
  <span style="color: #CC6600;">if</span>(irLval &gt; 200) {
    PLval = 850;
    PRval = 820;
    x = 5;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = <span style="color: #CC6600;">millis</span>();
  }
  <span style="color: #CC6600;">else</span> <span style="color: #CC6600;">if</span>(irCval &gt; 200) {
    PLval = 850;
    PRval = 820;
    x = 10;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = <span style="color: #CC6600;">millis</span>();
  }
  <span style="color: #CC6600;">else</span> <span style="color: #CC6600;">if</span>(irRval &gt; 200) {
    PLval = 650;
    PRval = 620;
    x = 5;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = <span style="color: #CC6600;">millis</span>();
  }
  <span style="color: #CC6600;">else</span> {
    x = 1;
    PLval = 850;
    PRval = 620;
    counter = counter + 1;
    clrpth = (<span style="color: #CC6600;">millis</span>() - objdet);
    <span style="color: #CC6600;">if</span>(add == <span style="color: #CC6600;">true</span>) {
      pwm = pwm + 50;
    }
    <span style="color: #CC6600;">else</span> <span style="color: #CC6600;">if</span>(add == <span style="color: #CC6600;">false</span>) {
      pwm = pwm - 50;
    }
    <span style="color: #CC6600;">if</span>(pwm &lt; 400) {
      pwm = 400;
      add = <span style="color: #CC6600;">true</span>;
    }
    <span style="color: #CC6600;">if</span>(pwm &gt; 950) {
      pwm = 950;
      add = <span style="color: #CC6600;">false</span>;
    }
    <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">HIGH</span>);
    <span style="color: #CC6600;">delayMicroseconds</span>(pwm * 2);
    <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">LOW</span>);
    <span style="color: #CC6600;">delay</span>(20);
    readPing();
    <span style="color: #CC6600;">if</span>(ultrasoundValue &lt; 500) {
      cntr = cntr + 1;
      <span style="color: #CC6600;">switch</span>(pwm) {
        <span style="color: #CC6600;">case</span> 400:
          x = 7;
          PLval = 650;
          PRval = 650;
          Go();
          break;
        <span style="color: #CC6600;">case</span> 500:
          x = 10;
          PLval = 650;
          PRval = 650;
          Go();
          break;
        <span style="color: #CC6600;">case</span> 600:
          x = 14;
          PLval = 850;
          PRval = 850;
          Go();
          break;
        <span style="color: #CC6600;">case</span> 700:
          x = 10;
          PLval = 850;
          PRval = 850;
          Go();
          break;
        <span style="color: #CC6600;">case</span> 950:
          x = 7;
          PLval = 850;
          PRval = 850;
          Go();
          break;
      }
    }
  }
  <span style="color: #7E7E7E;">//Serial.print("clrpth: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(clrpth);</span>
  <span style="color: #7E7E7E;">//Serial.print("objdet: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(objdet);</span>
  <span style="color: #7E7E7E;">//Serial.print("cntr: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(cntr);</span>
  <span style="color: #CC6600;">if</span>(cntr &gt; 25 &amp;&amp; clrpth &lt; 2000) {
    clrpth = 0;
    cntr = 0;
    Scan();
  }
}
<span style="color: #CC6600;">void</span> Go() {
  <span style="color: #CC6600;">for</span>(i = 0; i &lt; x; i++) {
    <span style="color: #CC6600;">digitalWrite</span>(LeftPin, <span style="color: #006699;">HIGH</span>);
    <span style="color: #CC6600;">delayMicroseconds</span>(PLval * 2);
    <span style="color: #CC6600;">digitalWrite</span>(LeftPin, <span style="color: #006699;">LOW</span>);
    <span style="color: #CC6600;">digitalWrite</span>(RightPin, <span style="color: #006699;">HIGH</span>);
    <span style="color: #CC6600;">delayMicroseconds</span>(PRval * 2);
    <span style="color: #CC6600;">digitalWrite</span>(RightPin, <span style="color: #006699;">LOW</span>);
    <span style="color: #CC6600;">delay</span>(20);
  }
}
<span style="color: #CC6600;">void</span> readPing() {  <span style="color: #7E7E7E;">// Get Distance from Ultrasonic Ranger</span>
 timecount = 0;
 val = 0;
 <span style="color: #CC6600;">pinMode</span>(ultraSoundSignal, <span style="color: #006699;">OUTPUT</span>); <span style="color: #7E7E7E;">// Switch signalpin to output</span>

<span style="color: #7E7E7E;">/* Send low-high-low pulse to activate the trigger pulse of the sensor</span>
<span style="color: #7E7E7E;"> * -------------------------------------------------------------------</span>
<span style="color: #7E7E7E;"> */</span>

<span style="color: #CC6600;">digitalWrite</span>(ultraSoundSignal, <span style="color: #006699;">LOW</span>); <span style="color: #7E7E7E;">// Send low pulse</span>
<span style="color: #CC6600;">delayMicroseconds</span>(2); <span style="color: #7E7E7E;">// Wait for 2 microseconds</span>
<span style="color: #CC6600;">digitalWrite</span>(ultraSoundSignal, <span style="color: #006699;">HIGH</span>); <span style="color: #7E7E7E;">// Send high pulse</span>
<span style="color: #CC6600;">delayMicroseconds</span>(5); <span style="color: #7E7E7E;">// Wait for 5 microseconds</span>
<span style="color: #CC6600;">digitalWrite</span>(ultraSoundSignal, <span style="color: #006699;">LOW</span>); <span style="color: #7E7E7E;">// Holdoff</span>

<span style="color: #7E7E7E;">/* Listening for echo pulse</span>
<span style="color: #7E7E7E;"> * -------------------------------------------------------------------</span>
<span style="color: #7E7E7E;"> */</span>

<span style="color: #CC6600;">pinMode</span>(ultraSoundSignal, <span style="color: #006699;">INPUT</span>); <span style="color: #7E7E7E;">// Switch signalpin to input</span>
val = <span style="color: #CC6600;">digitalRead</span>(ultraSoundSignal); <span style="color: #7E7E7E;">// Append signal value to val</span>
<span style="color: #CC6600;">while</span>(val == <span style="color: #006699;">LOW</span>) { <span style="color: #7E7E7E;">// Loop until pin reads a high value</span>
  val = <span style="color: #CC6600;">digitalRead</span>(ultraSoundSignal);
}

<span style="color: #CC6600;">while</span>(val == <span style="color: #006699;">HIGH</span>) { <span style="color: #7E7E7E;">// Loop until pin reads a high value</span>
  val = <span style="color: #CC6600;">digitalRead</span>(ultraSoundSignal);
  timecount = timecount +1;            <span style="color: #7E7E7E;">// Count echo pulse time</span>
}

<span style="color: #7E7E7E;">/* Writing out values to the serial port</span>
<span style="color: #7E7E7E;"> * -------------------------------------------------------------------</span>
<span style="color: #7E7E7E;"> */</span>

ultrasoundValue = timecount; <span style="color: #7E7E7E;">// Append echo pulse time to ultrasoundValue</span>

<span style="color: #7E7E7E;">//serialWrite('A'); // Example identifier for the sensor</span>
<span style="color: #7E7E7E;">//printInteger(ultrasoundValue);</span>
<span style="color: #7E7E7E;">//serialWrite(10);</span>
<span style="color: #7E7E7E;">//serialWrite(13);</span>

<span style="color: #7E7E7E;">/* Lite up LED if any value is passed by the echo pulse</span>
<span style="color: #7E7E7E;"> * -------------------------------------------------------------------</span>
<span style="color: #7E7E7E;"> */</span>

<span style="color: #CC6600;">if</span>(timecount &gt; 0){
  <span style="color: #CC6600;">digitalWrite</span>(ledPin, <span style="color: #006699;">HIGH</span>);
}
} 
<span style="color: #CC6600;">void</span> Scan() {   <span style="color: #7E7E7E;">// Scan for the Clearest Path</span>
  oldDistance = 30;
  task = 0;
  <span style="color: #CC6600;">for</span>(i = 1; i &lt; 5; i++) {
    <span style="color: #CC6600;">switch</span>(i) {
      <span style="color: #CC6600;">case</span> 1:
        <span style="color: #7E7E7E;">//Serial.println("Pos. 1");</span>
        pwm = 1125;    <span style="color: #7E7E7E;">///  incr. by 100 from 1085</span>
        break;
      <span style="color: #CC6600;">case</span> 2:
        <span style="color: #7E7E7E;">//Serial.println("Pos. 2");</span>
        pwm = 850; <span style="color: #7E7E7E;">//// increased by 100 from 850</span>
        break;
      <span style="color: #CC6600;">case</span> 3:
        <span style="color: #7E7E7E;">//Serial.println("Pos. 3");</span>
        pwm = 400;
        break;
      <span style="color: #CC6600;">case</span> 4:
        <span style="color: #7E7E7E;">//Serial.println("Pos. 4");</span>
        pwm = 235;
        break;
    }
    <span style="color: #CC6600;">for</span>(pulseCount = 0; pulseCount &lt; 20; pulseCount++) {  <span style="color: #7E7E7E;">// Adjust Pan Servo and Read USR</span>
      <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">HIGH</span>);
      <span style="color: #CC6600;">delayMicroseconds</span>(pwm * 2);
      <span style="color: #CC6600;">digitalWrite</span>(PingServoPin, <span style="color: #006699;">LOW</span>);
      readPing();
      <span style="color: #CC6600;">delay</span>(20);
    }
    distance = ((<span style="color: #CC6600;">float</span>)ultrasoundValue * CmConstant);   <span style="color: #7E7E7E;">// Calculate Distance in Cm</span>
    <span style="color: #CC6600;">if</span>(distance &gt; oldDistance) {  <span style="color: #7E7E7E;">// If the Newest distance is longer, replace previous reading with it</span>
      oldDistance = distance;
      task = i;   <span style="color: #7E7E7E;">// Set task equal to Pan Servo Position</span>
    }
  }
  <span style="color: #7E7E7E;">//Serial.print("Task: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(task);</span>
  <span style="color: #7E7E7E;">//Serial.print("distance: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(distance);</span>
  <span style="color: #7E7E7E;">//Serial.print("oldDistance: ");</span>
  <span style="color: #7E7E7E;">//Serial.println(oldDistance);</span>
  distance = 50;  <span style="color: #7E7E7E;">// Prevents Scan from Looping</span>
  <span style="color: #CC6600;">switch</span>(task) {   <span style="color: #7E7E7E;">// Determine which task should be carried out</span>
    <span style="color: #CC6600;">case</span> 0:  <span style="color: #7E7E7E;">// Center was clearest</span>
      x = 28;
      PLval = (850);
      PRval = (850);
      Go();
      break;
    <span style="color: #CC6600;">case</span> 1:  <span style="color: #7E7E7E;">// 90 degrees Left was Clearest</span>
      x = 14;
      PLval = (650);
      PRval = (650);
      Go();
      break;
    <span style="color: #CC6600;">case</span> 2:  <span style="color: #7E7E7E;">// 45 degrees left</span>
      x = 7;
      PLval = (650);
      PRval = (650);
      Go();
      break;
    <span style="color: #CC6600;">case</span> 3:  <span style="color: #7E7E7E;">// 45 degrees right</span>
      x = 7;
      PLval = (850);
      PRval = (850);
      Go();
      break;
    <span style="color: #CC6600;">case</span> 4:  <span style="color: #7E7E7E;">// 90 degrees right</span>
      x = 14;
      PLval = (850);
      PRval = (850);
      Go();
      break;
  }
}

<span style="color: #7E7E7E;">// End Robot Code</span></pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farduinofun.com%2Fblog%2F2009%2F11%2F25%2Farduino-autonomous-robot%2F&amp;linkname=Arduino%20Autonomous%20Robot"><img src="http://arduinofun.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://arduinofun.com/blog/2009/11/25/arduino-autonomous-robot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Open Source ADM-Robot 1.0 (part 1)</title>
		<link>http://arduinofun.com/blog/2009/11/01/open-source-adm-robot-1-0-part-1/</link>
		<comments>http://arduinofun.com/blog/2009/11/01/open-source-adm-robot-1-0-part-1/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 18:37:13 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Project Files]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Arduino Project]]></category>
		<category><![CDATA[Arduino Robot]]></category>
		<category><![CDATA[Arduino Sketch]]></category>
		<category><![CDATA[GridConnect]]></category>
		<category><![CDATA[Open Source Project]]></category>
		<category><![CDATA[Open Source Robot]]></category>
		<category><![CDATA[PCB]]></category>
		<category><![CDATA[Printed Circuit Board]]></category>
		<category><![CDATA[Recycling]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[Science Fair Projects]]></category>
		<category><![CDATA[WiFly]]></category>

		<guid isPermaLink="false">http://arduinofun.com/blog/?p=174</guid>
		<description><![CDATA[It&#8217;s that time of year again&#8230; where the sounds of knowledge fill the home labs, garages and basements across the globe. Here in the ArduinoFun lab, we have been busy working on this years project ADM-Robot 1.0 aka Recycle-bot.
I will be posting progress photos and notes as we go along to document the process for [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_175" class="wp-caption alignleft" style="width: 330px"><img class="size-full wp-image-175" title="Drew and Jacob - Soldering boards" src="http://arduinofun.com/blog/wp-content/uploads/2009/11/sf1.jpg" alt="Drew and Jacob - Soldering boards" width="320" height="240" /><p class="wp-caption-text">Drew and Jacob - Soldering boards</p></div>
<p>It&#8217;s that time of year again&#8230; where the sounds of knowledge fill the home labs, garages and basements across the globe. Here in the ArduinoFun lab, we have been busy working on this years project ADM-Robot 1.0 aka Recycle-bot.</p>
<p>I will be posting progress photos and notes as we go along to document the process for our science fair project.</p>
<p>What is ADM 1.0? Basically we built an Arduino, added a Dual Motor Controller to it and a small prototyping area. Hence the name ADM (Arduino Dual Motor).  The board works and is programmed just like a normal Arduino. For the science fair, part of the rules stated we could not use an actual Arduino board, but were able to build or modify our own.<span id="more-174"></span></p>
<div id="attachment_176" class="wp-caption alignleft" style="width: 330px"><img class="size-full wp-image-176" title="Shawn and Jacob - Drilling component holes" src="http://arduinofun.com/blog/wp-content/uploads/2009/11/sf2.jpg" alt="Shawn and Jacob - Drilling component holes" width="320" height="240" /><p class="wp-caption-text">Shawn and Jacob - Drilling component holes</p></div>
<p>Below is a zip file which contains the files that will allow you to create your own PCB file. According to Drew and Jacob, Recycle bot will be used in school to help drive interest in getting classmates to start recycling. &#8220;Having a cool robot moving around the lunch room to collect your recyclables will encourage everyone to participate because it is so cool!&#8221;</p>
<p>We will be using a metal trash can that we found at the store that just looks like it was meant to be a robot.</p>
<p>To make a copy of the PCB, you can follow the <a href="http://www.instructables.com/id/Creating-Printed-Circuit-Boards-with-a-INKJET-Prin/">Instructable that I created</a> that uses a home Inkjet printer. The entire process works really well and the boards have turned out great.</p>
<p><a href="http://arduinofun.com/files/adm1.zip"></a></p>
<div id="attachment_183" class="wp-caption alignleft" style="width: 330px"><a><img class="size-full wp-image-183" title="Drew and Jacob - Prototyping ADM 1.0" src="http://arduinofun.com/blog/wp-content/uploads/2009/11/sf3.jpg" alt="Drew and Jacob - Prototyping ADM 1.0" width="320" height="240" /></a><p class="wp-caption-text">Drew and Jacob - Prototyping ADM 1.0</p></div>
<p><a href="http://arduinofun.com/files/adm1.zip">This zip file</a> contains two PDF files (solder side &amp; component side), for printing your own circuit board.</p>
<p>Once we get a little further along I will start posting some videos, photos and Arduino sketches that we use.</p>
<p>We are also working with <a href="http://www.gridconnect.com/wiflygsxkit.html">GridConnect</a> on a project, and hopefully if all goes well ADM will be enabled with WiFly</p>
<p>Board Photos on My <a href="http://www.flickr.com/photos/34908673@N00/">Flickr</a> Page.</p>
<p><a href="http://www.flickr.com/photos/34908673@N00/4067482659/">Component Side</a>, <a href="http://www.flickr.com/photos/34908673@N00/4068232404/">Solder Side</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farduinofun.com%2Fblog%2F2009%2F11%2F01%2Fopen-source-adm-robot-1-0-part-1%2F&amp;linkname=Open%20Source%20ADM-Robot%201.0%20%28part%201%29"><img src="http://arduinofun.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://arduinofun.com/blog/2009/11/01/open-source-adm-robot-1-0-part-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
