Step 8: Breadboard

Now, to once again use the letter analogy... time to put the E in MAEP! With a solderless breadboard, you can quickly make and de-make circuits to try out new things and not have to break out the soldering iron each time. Most breadboards of this size come with an adhesive backing, in which case you can just stick it on. I used a rubber band, which you can feel free to do. 
<p>Hello,</p><p>Is there someone who has the same code but with an 4 pin HC-SR04 Sensor?</p><p>Thanks</p><p>Jelmer</p>
<p>Even I want a code for a 4 pin !</p>
<p>Connect the Trig and Echo pins from your 4-pin sensor both to the same pin (pin 7). The code switches the pin mode between input and output on the fly so it can use one wire for both. The HC-SR04 doesn't care.</p><p>-OR-</p><p>If you don't want to do that, you need to connect Trig to pin 7 and connect Echo to a different pin and change the code to listen for input on that pin instead. </p><p>Untested, but basically:</p><p>* Plug echo into pin 8<br>* inthe code after &quot;const int pingPin = 7;&quot; add</p><p>const int echoPin = 8;</p><p>* change the code after &quot;//Get duration it takes to receive echo&quot; like so:</p><p>//Get duration it takes to receive echo<br>pinMode(echoPin, INPUT);<br>duration = pulseIn(echoPin, HIGH);</p><p>(you could also move the pin mode declarations up top since they're not changing modes any more, but you don't have to)</p>
<p>hi i m surya just connect it to a breadboard after that to the arduino digipin</p>
<p>Hey surya, Dint get you, Can you please explain it ?</p>
hello im just wondering. my left and right servo won't spin 360degrees but it only spin to 180 degrees.. how to make it spin to 360...
<p>A bit late but if you're still confused, you probably do not have a continuous rotation servo. Most servos cannot spin in a full circle and those that can are specially titled as continuous rotation servo. </p>
if you need help n code check here https://youtu.be/rcrzHPu0Q_8
Hello, i made this robot, made all the connections, uploaded the code to the arduino, but nothing happens. I unplugged the arduino, applied power from the 9v battery (via the Vin port thing), put the robot an an open space yet nothing happens. However, if i put my ear up close to it, i can hear a low, humming noise that i /think/ is comming from the servos
Hello,<br>Is there someone who has code for wall follwer in which left turn has higher priority than right using 3 ultrasonic sensors. Plz reply fast. It would be the great help
<p>First thank you all of you,now i am doing fire fighting robot project however i am facing some problem.which is we have to use the photo diode and IR LED rather than ultrasonic sensor for obstacle and distance sensor because of the availability.so please help me if is there a change in any one of the program and the circuit or if you have any idea which you think is you can tell me what i have to do</p>
<p>Is the photodiode and IRLed in one sensor? Like a Sharp IR Sensor (http://www.acroname.com/articles/sharp.html) ?</p><p>If so then it is very comparable to the Ultrasonic sensor, but the target area is very narrow and you may want a sweeping motion in your code that takes multiple readings then move the robot in the longest duration direction. There are many tutorials on the specifics of that sensor. Here are some links: </p><p><a href="http://www.instructables.com/id/Arduino-based-robot-with-IR-radar/" rel="nofollow">http://www.instructables.com/id/Arduino-based-robo...</a></p><p><a href="http://communityofrobots.com/tutorial/kawal/how-make-your-first-robot-using-arduino" rel="nofollow">http://communityofrobots.com/tutorial/kawal/how-ma...</a></p><p><a href="http://www.societyofrobots.com/sensors_sharpirrange.shtml" rel="nofollow">http://www.societyofrobots.com/sensors_sharpirrang...</a></p><p>Hope that helps.</p>
<p>i made it but it kills the battery too fast can someone tell me what can i do to make the battery last longer</p>
<p>You will need batteries that have a higher mAh (milli-Amp-hour) rating. Basically same voltage but bigger charge. OR You could add more batteries in parallel. Basically add two or more of the same batteries that you have by connecting positive to positive and negative to negative. This will double the charge but keep the same voltage. Look online for your battery type. </p>
<p>hey... i am new here..... can anyone tell me about the servo under the ultrasonic sensor.... plzzzz fast...</p>
<p>It seems to be an ordinary un-modified servo. It is used in conjunction with the ultrasonic servo to determine distance in three different angles (left, right and center) Your code will move the robot towards the angle that has the longest PING time, which has more open area.</p><p>I believe that the author did not include this third servo in the materials list. Six months isn't fast but I hope it helps.</p><p>:P</p>
<p>reply fast guys ....... its urgent !!!!!!!!!</p>
<p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/ZNwRAlUqKRM" width="500"></iframe></p><p>bot with ping added :)</p><p>Thanks again </p>
<p>hello , its a very nice robot ,<br>we have a project and we are new to almost every thing :) <br>but am gathering information any way<br>our robot going to hold objects , so i want it to not turn around when it reach it , instead , to stop , and hold it using magnatic or sth .. <br>can you please help me with the code<br>and how to stop when it reach a certain distance from the object , can we do that ? thanks a lot </p>
<p>can i replace servo using dc geared motors??</p>
Hi, <br>Could you help me with the problem I'm having with my robot PLEASE. <br>Basically I've used the code you have posted, but it didnt work so I made bit change but still it didnt work, the problem is my the servo with ultrasonic sensor on it keep on spinning left and right constantly even tho there is no obstacle in front. <br>And also the robot goes few steps forward and again spins the servo with the ultrasonic sensor. <br>By the way i'm using ultrasonic sensor with 4 pins (HC-SR04) <br>I would really appreciate, if u could correct it <br>Cheers <br> <br> <br> <br> <br>/*MAEP 2.0 Navigation <br>by Noah Moroze, aka GeneralGeek <br>This code has been released under a Attribution-NonCommercial-ShareAlike license, more info at http://creativecommons.org/licenses/ <br>PING))) code by David A. Mellis and Tom Igoe http://www.arduino.cc/en/Tutorial/Ping <br>*/ <br>#include //include Servo library <br> <br>const int RForward = 0; <br>const int RBackward = 180; <br>const int LForward = 0; <br>const int LBackward = 180; <br>const int RNeutral = 90; <br>const int LNeutral = 90; //constants for motor speed <br>const int trigpin = 7; <br>const int echopin = 3; <br>const int dangerThresh = 10; //threshold for obstacles (in cm) <br>int leftDistance, rightDistance; //distances on either side <br>Servo panMotor; <br>Servo leftMotor; <br>Servo rightMotor; //declare motors <br>long duration; //time it takes to recieve PING))) signal <br> <br>void setup() <br>{ <br> rightMotor.attach(11); <br> leftMotor.attach(10); <br> panMotor.attach(6); //attach motors to proper pins <br> panMotor.write(90); //set PING))) pan to center <br>} <br> <br>void loop() <br>{ <br> int distanceFwd = ping(); <br> if (distanceFwd&gt;dangerThresh) //if path is clear <br> { <br> leftMotor.write(LForward); <br> rightMotor.write(RForward); //move forward <br> } <br> else //if path is blocked <br> { <br> leftMotor.write(LNeutral); <br> rightMotor.write(RNeutral); <br> panMotor.write(0); <br> delay(500); <br> rightDistance = ping(); //scan to the right <br> delay(500); <br> panMotor.write(180); <br> delay(700); <br> leftDistance = ping(); //scan to the left <br> delay(500); <br> panMotor.write(90); //return to center <br> delay(100); <br> compareDistance(); <br> } <br>} <br> <br>void compareDistance() <br>{ <br> if (leftDistance&gt;rightDistance) //if left is less obstructed <br> { <br> leftMotor.write(LBackward); <br> rightMotor.write(RForward); //turn left <br> delay(500); <br> } <br> else if (rightDistance&gt;leftDistance) //if right is less obstructed <br> { <br> leftMotor.write(LForward); <br> rightMotor.write(RBackward); //turn right <br> delay(500); <br> } <br> else //if they are equally obstructed <br> { <br> leftMotor.write(LForward); <br> rightMotor.write(RBackward); //turn 180 degrees <br> delay(1000); <br> } <br>} <br> <br>long ping() <br>{ <br> // Send out PING))) signal pulse <br> pinMode(trigpin, OUTPUT); <br> pinMode(echopin,INPUT); <br> digitalWrite(trigpin, LOW); <br> delayMicroseconds(2); <br> digitalWrite(trigpin, HIGH); <br> delayMicroseconds(10); <br> digitalWrite(trigpin, LOW); <br> <br> //Get duration it takes to receive echo <br> <br> duration = pulseIn(echopin, HIGH); <br> <br> //Convert duration into distance <br> return duration / 29 / 2; <br>} <br>
<p>Are you using a continuous rotation servo for the PING sensor? You need a normal servo to get proper degrees for that servo. Continuous rotation servos merely spin cockwise, counter-clockwise, and stop using the values 180, 0, and 90 respectively.</p><p>The code looks fine and wouldn't cause the symptoms you describe.</p><p>:P</p>
Hi, this seems like it should work. Google how to use the Arduino serial port if you don't know how, then print out the duration variable in a loop. Test different distances, and see if the sensor is returning the right distance from the obstacle.
Hello all <br>I was thinking about making this awesome robot. But after reading the whole article and the code i got confused with the operation of the two servos that drive the wheels. <br>As far as i know, a contineous rotating servo has lost its control over the amount of degree to rotate. Then how can the wheel servo rotate 90&ordm; and 180&ordm;?
<p>With continuous rotation servos it acts more like a speed control. The servo commands execute until the potentiometer in the servo reaches a certain resistance that equals that degree then stops. The servo will never reach that resistance because the potentiometer is essentially disabled. So 90 degrees is center, 180 degrees is turn right (I think) and 0 is turn left.</p><p>I think the solutions for degrees of movement of the robot involve time and/or light sensors like photoresistors, on the the wheels to calculate degrees.</p>
<p>Hi, im trying to do this exact project and in addition to this i would like to add sound source tracking. could you anyone help?</p>
<p>Experiment with two microphones on Arduino analog pins and compare the two inputs similar to photo-resistors for light.</p>
<p>I notice you don't use a motor shield or diode protection on the breadboard. Isn't a safeguard needed against an inductance induced power spike when the servos are stopped? Also wouldn't the load of the two servos be very close to the maximum the Arduino can handle without being damaged? </p>
<p>le servo-moteur coute vers 10 euro en tant que le moteur simple coute 3 euro , tu sais pourquoi ? <br>parce que le servo-moteur est d&eacute;j&agrave; &eacute;quip&eacute; d'un moteur shield et protection complete dedans c'est pour cela il y a aucun risque a se montage :) </p>
<p>HI! :) mine is working pretty good thanks to you. and in fact i made some changes and it was perfectly working to..</p>
<p>Is it possible to make this with the Dagu Rover 5 Tracked Robot Chassis?</p>
Hi love the idea and clear instuctions but just to be clear could you send a revised vertion of the code to me?<br>Thanks so much <br>John
<p>Hi i was able to take the code you and <a href="http://www.instructables.com/member/sangelek/" rel="nofollow">sangelek</a> so kindly provided and upgrade my Parallax arduino shield bot from IR Sensors to PING Sensor with very minor adjustments to the code..the shield i have has connections for 4 servo,s ,,,im only using 3 servos,, it has 5 aa battery's under the hood,, my ping sensor has 4 connections.. thanks to you guys i was able to figure it out.. here is a quick video of my bot with IR sensors. ---- <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/-Qz_SMl7hbk" width="500"></iframe> ---- . i will put up a new video today with my ping sensors on it.. and ill be sure to mention you guys .. thank you <a href="http://www.instructables.com/member/generalgeek314/" rel="nofollow">generalgeek314</a> &amp; <a href="http://www.instructables.com/member/sangelek/" rel="nofollow">sangelek</a></p><p>cheers Robbie</p><p></p><p>/*MAEP 2.0 Navigation </p><p>by Noah Moroze, aka GeneralGeek </p><p>This code has been released under a Attribution-NonCommercial-ShareAlike license, more info at <a href="http://creativecommons.org/licenses/" rel="nofollow"> http://creativecommons.org/licenses/ </a> </p><p>PING))) code by David A. Mellis and Tom Igoe <a href="http://www.arduino.cc/en/Tutorial/Ping" rel="nofollow"> http://www.arduino.cc/en/Tutorial/Ping </a> </p><p>*/ </p><p>#include &lt;Servo.h&gt;//include Servo library </p><p>const int RForward = 0; </p><p>const int RBackward = 180; </p><p>const int LForward = 180; </p><p>const int LBackward = 0; </p><p>const int RNeutral = 90; </p><p>const int LNeutral = 90; //constants for motor speed </p><p>const int trigpin = 7; </p><p>const int echopin = 3; </p><p>const int dangerThresh = 10; //threshold for obstacles (in cm) </p><p>int leftDistance, rightDistance; //distances on either side </p><p>Servo panMotor; </p><p>Servo leftMotor; </p><p>Servo rightMotor; //declare motors </p><p>long duration; //time it takes to recieve PING))) signal </p><p>void setup() </p><p>{ </p><p>rightMotor.attach(12); </p><p>leftMotor.attach(13); </p><p>panMotor.attach(11); //attach motors to proper pins </p><p>panMotor.write(90); //set PING))) pan to center </p><p>} </p><p>void loop() </p><p>{ </p><p>int distanceFwd = ping(); </p><p>if (distanceFwd&gt;dangerThresh) //if path is clear </p><p>{ </p><p>leftMotor.write(LForward); </p><p>rightMotor.write(RForward); //move forward </p><p>} </p><p>else //if path is blocked </p><p>{ </p><p>leftMotor.write(LNeutral); </p><p>rightMotor.write(RNeutral); </p><p>panMotor.write(0); </p><p>delay(500); </p><p>rightDistance = ping(); //scan to the right </p><p>delay(500); </p><p>panMotor.write(180); </p><p>delay(700); </p><p>leftDistance = ping(); //scan to the left </p><p>delay(500); </p><p>panMotor.write(90); //return to center </p><p>delay(100); </p><p>compareDistance(); </p><p>} </p><p>} </p><p>void compareDistance() </p><p>{ </p><p>if (leftDistance&gt;rightDistance) //if left is less obstructed </p><p>{ </p><p>leftMotor.write(LBackward); </p><p>rightMotor.write(RForward); //turn left </p><p>delay(500); </p><p>} </p><p>else if (rightDistance&gt;leftDistance) //if right is less obstructed </p><p>{ </p><p>leftMotor.write(LForward); </p><p>rightMotor.write(RBackward); //turn right </p><p>delay(500); </p><p>} </p><p>else //if they are equally obstructed </p><p>{ </p><p>leftMotor.write(LForward); </p><p>rightMotor.write(RBackward); //turn 180 degrees </p><p>delay(1000); </p><p>} </p><p>} </p><p>long ping() </p><p>{ </p><p>// Send out PING))) signal pulse </p><p>pinMode(trigpin, OUTPUT); </p><p>pinMode(echopin,INPUT); </p><p>digitalWrite(trigpin, LOW); </p><p>delayMicroseconds(2); </p><p>digitalWrite(trigpin, HIGH); </p><p>delayMicroseconds(10); </p><p>digitalWrite(trigpin, LOW); </p><p>//Get duration it takes to receive echo </p><p>duration = pulseIn(echopin, HIGH); </p><p>//Convert duration into distance </p><p>return duration / 29 / 2; </p><p>} </p>
Hi I'm new to here. I already make that without any problems. Thanks all . So now i need to remove this servos and put motors here. So how can i do that? <br>
can i use Roboduino ATMega8 (Based on Arduino Diecimila) instead of arduino uno......? <br>or can u suggest me a cheaper one
can i use a readymade chassis because i cant get the aluminium chassis you used.
hey <br>i also wannna do a similar stuff. i want to design a robot for surveillance where the robot will be fully autonomous and it wil move for point A to point B autonomously. <br>i want u to help me in designing the autonomous motion planning system to go form one given place to the other using sensors n stuff...i m stuck pls help <br> <br>i have bought the rover system from here just for making prototype of the actual system since i got it at a good price... <br>http://danuc.com/index.php?main_page=index&amp;cPath=6 <br>http://danuc.com/index.php?main_page=index&amp;cPath=4 <br>http://danuc.com/index.php?main_page=index&amp;cPath=1 <br>http://danuc.com/index.php?main_page=index&amp;cPath=7 <br>http://danuc.com/index.php?main_page=product_info&amp;cPath=8&amp;products_id=52 <br> <br>pls reply
How can we connect 3 connections to a single 5v.
How to connect the left and right servo and the servo panning servo.
hi,,i made this using two IR sensors in robotic controller M1,will u plz send me the code ,,,i made it using flowcode AVR ,but got some errors and cant find how,,,so plz help
Thank you for the first code. I figured out how to open the center servo code And built the robot. Instead of using an arduino UNO I used an arduino nano and put it in an altoids tin. You can check it out at YouTube here: http://m.youtube.com/watch?v=KbMGGeGTqso
can you also put the center servo code
//Center Servos <br>#include <br> <br>Servo servo; <br> <br>void setup() <br>{ <br> servo.attach(11); <br>} <br> <br>void loop() <br>{ <br> servo.write(90); <br>} <br> <br>
What would I need to change in order to use a 4-pin sensor? I have the HC-SR04. Thanks!!
I think some of the comments below have addressed this concern already. Good luck with your robot!
You're welcome!
hey can you put the code in the comments because I'm having a hard time opening the code attachment
Sorry it took me so long to reply<br> <br> /*MAEP 2.0 Navigation<br> by Noah Moroze, aka GeneralGeek<br> This code has been released under a Attribution-NonCommercial-ShareAlike license, more info at http://creativecommons.org/licenses/<br> PING))) code by David A. Mellis and Tom Igoe http://www.arduino.cc/en/Tutorial/Ping<br> */<br> <br> #include &lt;Servo.h&gt; //include Servo library<br> <br> const int RForward = 0;<br> const int RBackward = 180;<br> const int LForward = RBackward;<br> const int LBackward = RForward;<br> const int RNeutral = 90;<br> const int LNeutral = 90; //constants for motor speed<br> const int pingPin = 7;<br> const int irPin = 0;&nbsp; //Sharp infrared sensor pin<br> const int dangerThresh = 10; //threshold for obstacles (in cm)<br> int leftDistance, rightDistance; //distances on either side<br> Servo panMotor;&nbsp;<br> Servo leftMotor;<br> Servo rightMotor; //declare motors<br> long duration; //time it takes to recieve PING))) signal<br> <br> void setup()<br> {<br> &nbsp; rightMotor.attach(11);<br> &nbsp; leftMotor.attach(10);<br> &nbsp; panMotor.attach(6); //attach motors to proper pins<br> &nbsp; panMotor.write(90); //set PING))) pan to center<br> }<br> <br> void loop()<br> {<br> &nbsp; int distanceFwd = ping();<br> &nbsp; if (distanceFwd&gt;dangerThresh) //if path is clear<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; leftMotor.write(LForward);<br> &nbsp;&nbsp;&nbsp; rightMotor.write(RForward); //move forward<br> &nbsp; }<br> &nbsp; else //if path is blocked<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; leftMotor.write(LNeutral);<br> &nbsp;&nbsp;&nbsp; rightMotor.write(RNeutral);<br> &nbsp;&nbsp;&nbsp; panMotor.write(0);<br> &nbsp;&nbsp;&nbsp; delay(500);<br> &nbsp;&nbsp;&nbsp; rightDistance = ping(); //scan to the right<br> &nbsp;&nbsp;&nbsp; delay(500);<br> &nbsp;&nbsp;&nbsp; panMotor.write(180);<br> &nbsp;&nbsp;&nbsp; delay(700);<br> &nbsp;&nbsp;&nbsp; leftDistance = ping(); //scan to the left<br> &nbsp;&nbsp;&nbsp; delay(500);<br> &nbsp;&nbsp;&nbsp; panMotor.write(90); //return to center<br> &nbsp;&nbsp;&nbsp; delay(100);<br> &nbsp;&nbsp;&nbsp; compareDistance();<br> &nbsp; }<br> }<br> &nbsp;<br> void compareDistance()<br> {<br> &nbsp; if (leftDistance&gt;rightDistance) //if left is less obstructed<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; leftMotor.write(LBackward);<br> &nbsp;&nbsp;&nbsp; rightMotor.write(RForward); //turn left<br> &nbsp;&nbsp;&nbsp; delay(500);<br> &nbsp; }<br> &nbsp; else if (rightDistance&gt;leftDistance) //if right is less obstructed<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; leftMotor.write(LForward);<br> &nbsp;&nbsp;&nbsp; rightMotor.write(RBackward); //turn right<br> &nbsp;&nbsp;&nbsp; delay(500);<br> &nbsp; }<br> &nbsp;&nbsp; else //if they are equally obstructed<br> &nbsp; {<br> &nbsp;&nbsp;&nbsp; leftMotor.write(LForward);<br> &nbsp;&nbsp;&nbsp; rightMotor.write(RBackward); //turn 180 degrees<br> &nbsp;&nbsp;&nbsp; delay(1000);<br> &nbsp; }<br> }<br> <br> long ping()<br> {<br> &nbsp; // Send out PING))) signal pulse<br> &nbsp; pinMode(pingPin, OUTPUT);<br> &nbsp; digitalWrite(pingPin, LOW);<br> &nbsp; delayMicroseconds(2);<br> &nbsp; digitalWrite(pingPin, HIGH);<br> &nbsp; delayMicroseconds(5);<br> &nbsp; digitalWrite(pingPin, LOW);<br> &nbsp;<br> &nbsp; //Get duration it takes to receive echo<br> &nbsp; pinMode(pingPin, INPUT);<br> &nbsp; duration = pulseIn(pingPin, HIGH);<br> &nbsp;<br> &nbsp; //Convert duration into distance<br> &nbsp; return duration / 29 / 2;<br> }

About This Instructable


203 favorites


Bio: A kid who is passionate about robotics, electronics, and computer programming.
More by generalgeek314: How To Make an Obstacle Avoiding Arduino Robot
Add instructable to: