Part4
Installing the Arduino Software
-
1Download and extract the Arduino IDE. This is the Arduino development environment, and allows you to program instructions that you can then upload to your Arduino microcontroller. You can download it for free from arduino.cc/en/main/software. Unzip the downloaded file by double-clicking it and move the folder inside to an easy to access location. You won't be actually installing the program. Instead, you'll just run it from the extracted folder by double-clicking arduino.exe.
-
2Connect the battery pack to the Arduino. Plug the battery back jack into the connector on the Arduino to give it power.
-
3Plug the Arduino into your computer via USB. Windows will likely not recognize the device.
-
4Press .⊞ Win+R and type devmgmt.msc. This will launch the Device Manager.
-
5Right-click on the "Unknown device" in the "Other devices" section and select "Update Driver Software." If you don't see this option, click "Properties" instead, select the "Driver" tab, and then click "Update Driver."
-
6Select "Browse my computer for driver software." This will allow you to select the driver that came with the Arduino IDE.
-
7Click "Browse" then navigate to the folder that you extracted earlier. You'll find a "drivers" folder inside.
-
8Select the "drivers" folder and click "OK." Confirm that you want to proceed if you're warned about unknown software.
Part5
Programming the Robot
-
1Start the Arduino IDE by double-clicking the arduino.exe file in the IDE folder.You'll be greeted with a blank project.
-
2Paste the following code to make your robot go straight. The code below will make your Arduino continuously move forward.
#include <Servo.h> // this adds the "Servo" library to the program // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); // if you accidentally switched up the pin numbers for your servos, you can swap the numbers here rightMotor.attach(13); } void loop() { leftMotor.write(180); // with continuous rotation, 180 tells the servo to move at full speed "forward." rightMotor.write(0); // if both of these are at 180, the robot will go in a circle because the servos are flipped. "0" tells it to move full speed "backwards." }
-
3Build and upload the program. Click the right arrow button in the upper-left corner to build and upload the program to the connected Arduino.
- You may want to lift the robot off of the surface, as it will just continue to move forward once the program is uploaded.
-
4Add the kill switch functionality. Add the following code to the "void loop()" section of your code to enable the kill switch, above the "write()" functions.
if(digitalRead(2) == HIGH) // this registers when the button is pressed on pin 2 of the Arduino { while(1) { leftMotor.write(90); // "90" is neutral position for the servos, which tells them to stop turning rightMotor.write(90); } }
-
5Upload and test your code. With the kill switch code added, you can upload and test the robot. It should continue to drive forward until you press the switch, at which point it will stop moving. The full code should look like this:
#include <Servo.h> // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); rightMotor.attach(13); } void loop() { if(digitalRead(2) == HIGH) { while(1) { leftMotor.write(90); rightMotor.write(90); } } leftMotor.write(180); rightMotor.write(0); }
You're helping people by reading a blog.

wikiHow's mission is to help people learn, and we really hope this article helped you. Now you are helping others, just by visiting wikiHow.
Direct Relief is a humanitarian nonprofit with a mission to improve the health and lives of people affected by poverty and emergencies. Recognized by Charity Navigator and Forbes for its efficiency, Direct Relief equips health professionals in the U.S. and throughout the world with essential medical resources to effectively treat and care for patients – without regard to politics, religion, or ability to pay.
Click below to let us know you read this article, and blog will donate to Direct Relief on your behalf. Thanks for helping us achieve our mission of helping everyone learn how to do anything....
Direct Relief is a humanitarian nonprofit with a mission to improve the health and lives of people affected by poverty and emergencies. Recognized by Charity Navigator and Forbes for its efficiency, Direct Relief equips health professionals in the U.S. and throughout the world with essential medical resources to effectively treat and care for patients – without regard to politics, religion, or ability to pay.
Click below to let us know you read this article, and blog will donate to Direct Relief on your behalf. Thanks for helping us achieve our mission of helping everyone learn how to do anything....
No comments:
Post a Comment