Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: JSH21 on August 22, 2008, 02:06:02 PM

Title: Arduino Code
Post by: JSH21 on August 22, 2008, 02:06:02 PM
OK, i am making a wall avoiding robot being driven by 2 continuous rotation servo motors, with a Sharp GP2D12 IR sensor and was wondering if anyone had a code for doing such task. It is using an Arduino Diecimila board, and i have checked several posts and sites for a code but most of them use ultrasonic sensors or are driven by motors instead of servos. So any help would be appreciated

and also, is this the correct way to connect the sensors and servo's to the board?
http://www.societyofrobots.com/robotforum/index.php?action=dlattach;topic=3653.0;attach=1420;image
Title: Re: Arduino Code
Post by: airman00 on August 22, 2008, 04:49:15 PM
http://www.societyofrobots.com/member_tutorials/node/45
Title: Re: Arduino Code
Post by: JSH21 on August 22, 2008, 09:34:43 PM
This tutorial uses motors to move the robot, but my robot is using continuous rotation servos
Title: Re: Arduino Code
Post by: JSH21 on August 22, 2008, 09:36:04 PM
and an ultrasonic sensor not IR
Title: Re: Arduino Code
Post by: Ro-Bot-X on August 23, 2008, 05:56:17 AM
Ok, to use the servo motors with Arduino, you have to download and install the Servo.h library from here: http://www.arduino.cc/playground/uploads/ComponentLib/servo.zip (http://www.arduino.cc/playground/uploads/ComponentLib/servo.zip) and read about using it here: http://www.arduino.cc/playground/ComponentLib/Servo (http://www.arduino.cc/playground/ComponentLib/Servo)

You can read about using a GP2D12 sensor here: http://www.arduino.cc/playground/Main/ReadGp2d12Range (http://www.arduino.cc/playground/Main/ReadGp2d12Range)

Good luck!

Edit: Yes, the image shows the correct way to connect the servos and the sensor to Arduino board. There is a page that shows the way to connect different things to Arduino here: http://wiring.org.co/learning/tutorials/diagrams.html (http://wiring.org.co/learning/tutorials/diagrams.html)
Title: Re: Arduino Code
Post by: JSH21 on August 23, 2008, 09:14:11 AM
Thank you very much!:) that helped A LOT
but just one more question, how do you get the servo library from the file from the first link?
Is it actually a software that controls servo's or is it somehting you have to add on and to where?
and do i still write all my codes into the "blink" software that i used to test the flashing LED?
or is there another program i use?
Title: Re: Arduino Code
Post by: Ro-Bot-X on August 24, 2008, 06:33:09 AM
Quote from the second link:
Quote
You can find the code in http://www.arduino.cc/playground/uploads/ComponentLib/servo.zip. Unpack that into your lib/targets/libraries folder to add the library.

Everything you need is explained there. Take some time to read through and use the links on the left to see other code samples, even if they are not related to what you need to do. It will help you understand how things are working in the Arduino software.
Title: Re: Arduino Code
Post by: JSH21 on August 24, 2008, 10:23:27 AM
I cant seem to find the location where you are suipposed to unpack the files
Title: Re: Arduino Code
Post by: Admin on August 28, 2008, 07:51:39 PM
This uses the same microcontroller as the Arduino:
http://www.societyofrobots.com/robot_50_robot_sharpIR.shtml