Arduino Uno R3 DIY Smart Bluetooth Car User Manual

1y ago
3 Views
2 Downloads
1.54 MB
19 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Lee Brooke
Transcription

Arduino Uno R3 DIY Smart Bluetooth Car User Manual Installation Instructions: To get started, we’ll attach the motors and the H bridge (the card that delivers power to the motors) to the lower part of the chassis. First, attach the four metal brackets (they’re rectangular, drilled blocks of metal) to each motor using two long bolts and two nuts. You’ll need to make sure that they’re attached correctly, so check out the image below to make sure that the side of the block with two drilled holes will face downward. Note that the wires on each motor are pointing toward the center of the chassis. www.ekt2.com

Now each motor can be attached to the chassis by using two short bolts in the bottom of each metal bracket. Here’s a view of the bottom of the chassis so you can see where the bolts need to be: The next step is to secure the H bridge (that’s the red board, in my kit) to the chassis. You may want to wait until all of the wires are attached to the H bridge before doing this, but that’s up to you. You can see here where the bolts and nuts would have gone: Now that the H bridge has been attached, you can start wiring up the power supply. Because the battery holder comes with a DC adapter, you’ll need to either cut off the end or run jumper wires to the batteries themselves. No matter how you decide to do it, you’ll run the positive wire to the port labelled “VMS” and the negative wire to the one labelled “GND” on the bridge. Screw down the fasteners and make sure they’re secure. Then, you’ll connect the motor wires. On both sides, there’s a set of two ports; one is labelled “MOTORA” and the other “MOTORB.” Both red wires on each side will go into the centermost green port, and both black wires will go into the outermost. This picture should make it clearer: www.ekt2.com

You’ll have to strip some of the housing off of the motor wires to get this to work. Now that you have the motors and the power supply all wired up, slide the wheels onto the motor drive shafts, and attach the four copper shafts in the locations show in the picture below (each copper shaft needs one small bolt). This r obot is starting to take shape! Now, set that part of the chassis aside and grab the other one which will sit on top. The next step is to attach the Arduino—again, you may use electrical tape, or better secure with some bolts and nuts. www.ekt2.com

The next step requires the micro servo, the black crosspiece, the servo holder (which consists of three black plastic pieces), and some small screws. Use one of the larger sharp screws in the kit to attach the black crosspiece to the micro servo: Then flip the servo upside down into the black plastic ring of the holder. Make sure that the wires coming out of the servo are facing in the same direction as the longer part of the holder (again, see the image below), and use four tiny screws to secure the crossbar (there are four holes in the holder that align with the holes on the crossbar). Here’s what it looks like after it’s attached: Finally, take the other two pieces of the servo holder and snap them onto the servo (there are grooves in the side pieces that match the plastic tab on the servo). www.ekt2.com

Now that the servo holder is complete, it can be mounted to the chassis. Here’s where the bolts go: It’s time to give our robot some eyes. Attach the ultrasonic sensor to the servo holder using two zip ties. www.ekt2.com

You can pop the Arduino sensor shield on top of the UNO now if you want (as in the image below). Just align the pins on the bottom of the shield with the I/O ports on the Arduino and press down to connect them. Whether you connect a sensor shield or not, you’ll now need four wires to connect the ultrasonic sensor to the Arduino. There are four pins on the sensor, VCC, GND, TRIG, and ECHO. Connect VCC to the 5V pin on the Arduino, GND to GND, and TRIG and ECHO to I/O pins 12 and 13. Now grab the lower part of the chassis, and connect six jumper wires to the I/O pins of the H bridge (they’re marked ENA, IN1, IN2, IN3, IN4, and ENB). Take note of which color wires are connected to which ports, as you’ll need to know later. www.ekt2.com

Now it’s time to start putting this thing together. Grab the upper part of the chassis and set it on top of the copper shafts connected to the lower part, and pull the wires attached to the H bridge through the hole in the center of the chassis. Connect the six wires to I/O ports as follows: ENA to I/O port 11 ENB to I/O port 10 A1 to I/O port 5 A2 to I/O port 6 B1 to I/O port 4 B2 to I/O port 3 Now, use four short screws to attach the upper part of the chassis to the copper shafts. Set the six -AA battery holder on top of the chassis (screw it down if you can), attach the 9V cell holder to the Arduino, and this bot is ready to rock! Well, almost ready to rock. It doesn’t have quite enough personality yet. www.ekt2.com

There we go. Now to give it a brain. Let’s do some programming. The first thing we’ll do is test to make sure that the bridge and motors are hooked up correctly. Here’s a quick sketch that will tell the bot to drive forward for half a second, drive backward for half a second, then turn left and right: //Go backward backward(200); //Turn left turnLeft(400); coast(200); //Turn right turnRight(400); coast(200); //This stops the loop run false; } } //Define high-level H-bridge commands void enableMotors() { www.ekt2.com

motorAOn(); motorBOn(); } void disableMotors() { motorAOff(); motorBOff(); } void forward(int time) { motorAForward(); motorBForward(); delay(time); } void backward(int time) { motorABackward(); motorBBackward(); delay(time); } void turnLeft(int time) { motorABackward(); motorBForward(); delay(time); } void turnRight(int time) www.ekt2.com

{ motorAForward(); motorBBackward(); delay(time); } void coast(int time) { motorACoast(); motorBCoast(); delay(time); } void brake(int time) { motorABrake(); motorBBrake(); delay(time); } //Define low-level H-bridge commands //enable motors void motorAOn() { digitalWrite(enableA, HIGH); } void motorBOn() { digitalWrite(enableB, HIGH); } www.ekt2.com

//disable motors void motorAOff() { digitalWrite(enableB, LOW); } void motorBOff() { digitalWrite(enableA, LOW); } //motor A controls void motorAForward() { digitalWrite(pinA1, HIGH); digitalWrite(pinA2, LOW); } void motorABackward() { digitalWrite(pinA1, LOW); digitalWrite(pinA2, HIGH); } //motor B controls void motorBForward() { digitalWrite(pinB1, HIGH); digitalWrite(pinB2, LOW); } void motorBBackward() www.ekt2.com

{ digitalWrite(pinB1, LOW); digitalWrite(pinB2, HIGH); } //coasting and braking void motorACoast() { digitalWrite(pinA1, LOW); digitalWrite(pinA2, LOW); } void motorABrake() { digitalWrite(pinA1, HIGH); digitalWrite(pinA2, HIGH); } void motorBCoast() { digitalWrite(pinB1, LOW); digitalWrite(pinB2, LOW); } void motorBBrake() { digitalWrite(pinB1, HIGH); digitalWrite(pinB2, HIGH); } If something went wrong, check all of your connections and that the wires are connected to the correct pins. If everything worked, it’s time to move onto the sensor test. To use the ultrasonic sensor, you’ll want to download the NewPing library, and then use Sketch Include Library Add .ZIP Library to load the library. www.ekt2.com

Make sure that you see the include statement at the top of your sketch; if you don’t, hit Sketch Include Library NewPing. Once you’ve done that, load up the following sketch: #include NewPing.h //Tell the Arduino where the sensor is hooked up NewPing sonar(12, 13); long inches; void setup() { //Activate the serial monitor so you can see the output of the sensor Serial.begin(9600); } void loop() { delay(50); //Ping the sensor to determine distance in inches inches sonar.ping in(); //Print the distance in inches to the serial monitor Serial.print(inches); Serial.print(" in."); Serial.print("\n"); } www.ekt2.com

Upload the sketch, and open up the serial monitor using Tools Serial Monitor. You should see a rapidly updating sequence of numbers. Hold your hand in front of the sensor and see if that number changes. Move your hand in and out, and you should get a measurement of how far away your hand is from the sensor . If everything worked correctly, it’s time to put it all together and let this thing run! Here’s the code for the robot now. As you can probably tell, this is basically the two test sketches put together with an added if statement to control the robot’s behavior. We’ve given it a very simple obstacle -avoidance behavior: if it detects something less than four inches away, it will backup, turn left, and start moving again. Her e’s a video of the bot in action. #include NewPing.h //Tell the Arduino where the sensor is hooked up NewPing sonar(12, 13); int enableA 11; int pinA1 6; int pinA2 5; int enableB 10; int pinB1 4; int pinB2 3; long inches; www.ekt2.com

void setup() { pinMode(enableA, OUTPUT); pinMode(pinA1, OUTPUT); pinMode(pinA2, OUTPUT); pinMode(enableB, OUTPUT); pinMode(pinB1, OUTPUT); pinMode(pinB2, OUTPUT); } void loop() { //Run the motors at slightly less than full power analogWrite(enableA, 200); analogWrite(enableB, 200); //Ping the sensor and determine the distance in inches inches sonar.ping in(); //If the robot detects an obstacle less than four inches away, it will back up, then turn left; if no obstacle is detected, it will go forward if (inches 4) { analogWrite(enableA, 255); analogWrite(enableB, 255); backward(600); coast(200); turnLeft(600); coast(200);} else { forward(1); } } //Define high-level H-bridge commands void enableMotors() { motorAOn(); www.ekt2.com

motorBOn(); } void disableMotors() { motorAOff(); motorBOff(); } void forward(int time) { motorAForward(); motorBForward(); delay(time); } void backward(int time) { motorABackward(); motorBBackward(); delay(time); } void turnLeft(int time) { motorABackward(); motorBForward(); delay(time); } void turnRight(int time) { motorAForward(); motorBBackward(); delay(time); } void coast(int time) { motorACoast(); motorBCoast(); delay(time); } www.ekt2.com

void brake(int time) { motorABrake(); motorBBrake(); delay(time); } //Define low-level H-bridge commands //enable motors void motorAOn() { digitalWrite(enableA, HIGH); } void motorBOn() { digitalWrite(enableB, HIGH); } //disable motors void motorAOff() { digitalWrite(enableB, LOW); } void motorBOff() { digitalWrite(enableA, LOW); } //motor A controls void motorAForward() { digitalWrite(pinA1, HIGH); digitalWrite(pinA2, LOW); } void motorABackward() { digitalWrite(pinA1, LOW); digitalWrite(pinA2, HIGH); www.ekt2.com

} //motor B controls void motorBForward() { digitalWrite(pinB1, HIGH); digitalWrite(pinB2, LOW); } void motorBBackward() { digitalWrite(pinB1, LOW); digitalWrite(pinB2, HIGH); } //coasting and braking void motorACoast() { digitalWrite(pinA1, LOW); digitalWrite(pinA2, LOW); } void motorABrake() { digitalWrite(pinA1, HIGH); digitalWrite(pinA2, HIGH); } void motorBCoast() { digitalWrite(pinB1, LOW); digitalWrite(pinB2, LOW); } void motorBBrake() { digitalWrite(pinB1, HIGH); digitalWrite(pinB2, HIGH); } } www.ekt2.com

Once you’ve gotten this behavior working correctly, you can add more complex behavior; make the robot alternate between turning left and right, or choose randomly; sound a buzzer if it gets close to something; just turn, instead of backing up; you’re really only limited by your imagination. You could use just about anything in your Arduino starter kit to add more functionality. You’ll notice also that we haven’t coded anything for the servo yet: you can actually makes your robot’s “eyes” move back and forth, perhaps using them to seek out a path instead of just backing up whenever it finds an obstacle directly in front. www.ekt2.com

Arduino Uno R3 DIY Smart Bluetooth Car User Manual Installation Instructions: To get started, we'll attach the motors and the H bridge (the card that delivers power to the motors) to the lower part of the chassis. First, attach the four metal brackets (they're rectangular, drilled blocks of metal) to each motor using two long bolts and two .

Related Documents:

Arduino compatible components. Personal computer running Arduino software Arduino software is free to download and use from: www.arduino.cc Arduino board Such as: Arduino Uno Freetronics Eleven Genuino Uno or any Arduino compatible board that has a standard Arduino UNO header l

3. Then, use the Arduino IDE to write code to send to Arduino. Once a code is sent to the Arduino, it lives on the Arduino Uno. Any future edits to that code on the computer will not be sent to the Arduino unless it is manually uploaded to the Arduino Uno. When using the Arduino

Arduino and Servo Motor Tutorial By: Matthew Jourden Brighton High School b. Arduino Shield: mounts on top of Arduino Uno board lining up the pins. The use of the shield is to expand the flexibility of the Arduino Uno board. 2. Link the Arduino Shield on top of the Arduino Board linking the proper pins to each port

the Arduino Uno Shield. 15.2.7. Connect the Arduino Uno to the PC via USB cable. 15.2.8. Note*- be sure that JP17/18 are not installed as this will prevent the code from downloading to the Arduino Uno board. 15.2.9. Download the DrDuino sketch to the Arduino Uno board by clicking on this button.

The Arduino Uno can be programmed with the (Arduino Software (IDE)). Select "Arduino/Genuino Uno from the Tools Board menu (according to the microcontroller on your board). For details, see the reference and tutorials. The ATmega328 on the Arduino Uno comes preprogrammed with a bootloader that allows you to

"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduno, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions, see the index of Arduino boards.

1. ARDUINO UNO 1.1 Introduction to Arduino UNO Fig.1.1 Arduino UNO Board Arduino is a popular open-source single-board microcontroller, descendant of the open-source Wiring platform, designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open hardware

arduino’s analog pin 4 (SDA). And the pin labelled as SCL on the MPU 6050 to the arduino’s analog pin 5 (SCL). And that’s it, you have finished wiring up the Arduino MPU 6050. Step 2: Uploading the code and testing the Arduino MPU 6050 To test the Arduino MPU 6050, first download the arduino library for MPU 6050, developed by Jeff Rowberg.