Step 10: Wire Breadboard and Sensor

Connect 5v to the positive column thingy in the breadboard. Connect GND to the negative thingy. Connect the yellow sensor thing to analog pin 2.
<p>Nice tutorial. I ended up modifying it to add a battery case with switch </p>
<p>muy bueno y facil de utilizar.</p>
very nice' but can we use a ultrasonic sensor in place of the SHARP sensor????????????
<p>can we use this module and normal male to female wires to connect it to the bread board?</p><p><a href="http://www.ebay.in/itm/Ultrasonic-Distance-Module-HC-SR04-Arduino-ARM-and-other-MCU-/141472357785?pt=IN_Toys_Games_School_Stuff&hash=item20f068dd99" rel="nofollow">http://www.ebay.in/itm/Ultrasonic-Distance-Module-HC-SR04-Arduino-ARM-and-other-MCU-/141472357785?pt=IN_Toys_Games_School_Stuff&amp;hash=item20f068dd99</a></p>
<p>can u pleast tell me the connections for this motor shield?</p><p><a href="http://www.ebay.com/itm/L293D-Motor-Drive-Shield-Expansion-Board-For-Arduino-Duemilanove-Mega-UNO-/221541254774?pt=LH_DefaultDomain_0&hash=item3394e34676" rel="nofollow">http://www.ebay.com/itm/L293D-Motor-Drive-Shield-Expansion-Board-For-Arduino-Duemilanove-Mega-UNO-/221541254774?pt=LH_DefaultDomain_0&amp;hash=item3394e34676</a></p><p>i would appreciate if u show the connections using a diagram </p>
<p>I'm having trouble installing the library.</p><p>I downloaded the zip file and imported the library, but when I put it in the sketch it only shows the .h file and gives me the error message: <br><br>core.a(main.cpp.o): In function `main': <br>C:\Program Files (x86)\Arduino\hardware\arduino\cores\ard... undefined reference to `setup' <br>C:\Program Files (x86)\Arduino\hardware\arduino\cores\ard... undefined reference to `loop' <br><br>The four &quot;example&quot; files show up in the sketchbook, but each opens in a new window. They individually verify, but when copy/pasting them together I get error messages. <br><br>I can't seem to import the .cpp file at all, and when I try to drag and drop it I get the same error message.</p>
does arduino uno r3 work
my brother would approve of your username, he has the same problem with his name.
Very nice tutorial. Simple and to-the-point. Thanks!
Glad I could help!
Hello Guys! <br> <br>Could i use Motorshields from this Collection? <br> <br>http://www.amazon.de/s/ref=nb_sb_noss?url=search-alias%3Daps&amp;field-keywords=Arduino+Motor+Shield+R3 <br> <br> <br>?? I cannot buy the Motorshield R3 on Amazon.US, because i dont have VISA or a Mastercard.
Yes, you could.
add a bluetooth slave to this to make it even better! cheap remote control car your android phone! I need to spend more time getting the ultrasonic sensor to work on my code. <br>Use BlueTerm from google play to control it. <br> <br>#include //motor shield <br>#include //Software Serial Port <br>#include // android link bluetooth <br>#define RxD 6 // BT com these are backwards on the shield <br>#define TxD 2 //BT com backwards on BT shield, jumpers <br>#define trigPin A4 //sensor trig to analog 4 <br>#define echoPin A5 //sensor echo to analog 5 <br>#define objLED A3 // set obsticle indicator led to analog 3 <br> <br>AF_DCMotor lmotor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm <br>AF_DCMotor rmotor(1, MOTOR12_64KHZ); // sets the left motor to port 1 <br> <br> <br> <br>SoftwareSerial blueToothSerial(RxD,TxD); <br> <br>void setup() <br>{ <br> Serial.begin(38400); // set up Serial library at 9600 bps <br> pinMode(RxD, INPUT); //set pin 6 to BT in <br> pinMode(TxD, OUTPUT); //set pin 2 to BT out <br> pinMode(trigPin, OUTPUT); //sets ultrasonic sensor <br> pinMode(echoPin, INPUT); <br> pinMode(objLED, OUTPUT); <br> setupBlueToothConnection(); // <br> rmotor.setSpeed(200); // set the RIGHT motot speed to 220 from 0 to 255 <br> lmotor.setSpeed(200); // set the Left motor speed to 200 from 0 to 255 <br>} <br> <br> <br>void loop() <br>{ <br> //get distance before collision <br> float duration, distance; <br> digitalWrite(trigPin, HIGH); <br> delayMicroseconds(1000); <br> digitalWrite(trigPin, LOW); <br> duration = pulseIn(echoPin, HIGH); <br> distance = (duration/2) / 29.1; <br> Serial.println(distance); <br> //end distance <br> <br> //recieve and execute comands via bluetooth <br> char recvChar; <br> <br> if(blueToothSerial.available())//check if there's any data sent from the remote bluetooth shield <br> { <br> recvChar = blueToothSerial.read(); <br> switch(recvChar) <br> { <br> case 'w': //forward <br> blueToothSerial.println(&quot;forward&quot;); <br> rmotor.run(FORWARD); <br> lmotor.run(FORWARD); <br> if(distance &lt;= 10 &amp;&amp; distance &gt;=1) // stop motor if distance is less than or equal to 10 cm <br> { <br> avoidObject(); <br> } <br> break; <br> <br> <br> case 's': //backwards <br> blueToothSerial.println(&quot;reverse&quot;); <br> rmotor.run(BACKWARD); <br> lmotor.run(BACKWARD); <br> break; <br> <br> case 'e': // stop <br> blueToothSerial.println(&quot;stopping&quot;); <br> rmotor.run(RELEASE); <br> lmotor.run(RELEASE); <br> break; <br> <br> case 'a': // turn left <br> blueToothSerial.println(&quot;turning left&quot;); <br> lmotor.run(FORWARD); <br> rmotor.run(BACKWARD); <br> break; <br> <br> case 'd': //turn right <br> blueToothSerial.println(&quot;turning right&quot;); <br> lmotor.run(BACKWARD); <br> rmotor.run(FORWARD); <br> break; <br> <br> }//end switch case <br> <br> <br> <br> } // end BT com <br> } // end loop <br> <br>void avoidObject() <br>{ <br> <br> digitalWrite(objLED,HIGH); <br> rmotor.run(RELEASE); <br> lmotor.run(RELEASE); <br> //delay(20); <br> rmotor.run(BACKWARD); <br> lmotor.run(BACKWARD); <br> delay(100); <br>} <br> <br>void setupBlueToothConnection() <br>{ <br> blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400 <br> blueToothSerial.print(&quot;\r\n+STWMOD=0\r\n&quot;); //set the bluetooth work in slave mode <br> blueToothSerial.print(&quot;\r\n+STNA=SeeedBTSlave\r\n&quot;); //set the bluetooth name as &quot;SeeedBTSlave&quot; <br> blueToothSerial.print(&quot;\r\n+STOAUT=1\r\n&quot;); // Permit Paired device to connect me <br> blueToothSerial.print(&quot;\r\n+STAUTO=0\r\n&quot;); // Auto-connection should be forbidden here <br> delay(2000); // This delay is required. <br> blueToothSerial.print(&quot;\r\n+INQ=1\r\n&quot;); //make the slave bluetooth inquirable <br> Serial.println(&quot;The slave bluetooth is inquirable!&quot;); <br> delay(2000); // This delay is required. <br> blueToothSerial.flush(); <br>}
The motor shield you are using has a relativly high current demand. One standard nine volt battery cannot supply that current. With my shield, I was needing power supplys with at leaste 800ma, and settled on using a 1600mah battery for all projects using that shield. Did the 9v battery actually drive the shield?
Yes, it works just fine for me.
Interesting. Your motors must not have a very large current consumption then.
Great tutorial, and just at the right time for me. My next project is to be a robot just like this. Thanks for the helping hand
(If you're going to glue your battery in place, best make sure it's rechargeable...?)
I didn't think that through very much, thanks for pointing that out. I think even if they were rechargeable, it would be difficult to recharge them while they're glued on. I suppose velcro, or some sort of holder would the best way to solve that problem.
You can get clips for the terminals, and clips for the actual battery - I'm guessing most folk will go that way. <br> <br>Since I have your attention, it would be nice to see a video of Carduino on the move...?
Video is soon to be posted.

About This Instructable




Bio: I am a human being that enjoys to build things. I also say GNU/Linux instead of just Linux. Yeah, I'm that kind of ...
More by alecnotalex:TouchPass: RFID Password Entry TiltKey- Write by Tilting RFI-DJ: MP3 Playing RFID Thing 
Add instructable to: