Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: First time programming anything here. on: February 25, 2011, 03:09:27 am
I will give the servo library a shot tomorrow, its gettin late and my head hurts from trying to pick up on all this just today haha. I will give it a shot and let you know how it goes. I feel it is unlikely this will solve my problem though.
2  Using Arduino / Sensors / Re: First time programming anything here. on: February 25, 2011, 03:03:48 am
originally I used a 9v batter to power the arduino. The 9 volts also went through a +5v low dropout voltage regulator. the +5v was used to power the servos. I ran into a problem when the servos wouldnt respond to the arduino signal. I realized that to properly work it seemed that to read the arduino signal properly the servo needed to be grounded to the on board ground, and not the ground in the voltage regulator circuit. So as it currently stands, the servo and ping are both being powered by the arduino boards onboard supply. How can I use an alternate power supply for the servos when they have different commons?
3  Using Arduino / Sensors / First time programming anything here. on: February 25, 2011, 02:49:58 am
Hi guys,

This is my first post. Im just getting into the arduino world and decided to try to build a robot. I am using an arduino uno, a ping ultrasonic sensor, and two springrc continuous rotation servos for my wheels.

I have used a program to control the servos successfully. I have used a program to use the ping successfully. The problem develops when I integrate the two. When the servos and ping are both in the program, the ping stops reading and shows 0's in the serial monitor. If i disconnect the servos' signal wires from the arduino then the ping works again fine, but as soon as one is plugged in, it no longer functions properly. I am unsure if the problem is something electrical or a problem with my program, so I am turning to you guys for help! Here is my code, its not done but it should be enough to identify a problem in the code if one exists


const int pingPin = 11;
const int servoR = 9;
const int servoL = 10;

long duration, inches, cm;

void setup()
   // initialize serial communication:
  pinMode (servoR,OUTPUT);
  pinMode (servoL,OUTPUT);

void go() {
  if (inches > 2){
  analogWrite(servoR, 170);
  analogWrite(servoL, 170);
    // BLAH BLAH havent worked out the turning routine yet but it will go here

void ping() {
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  Serial.print("in, ");

void loop() {

long microsecondsToInches(long microseconds)
  return microseconds / 74 / 2;

long microsecondsToCentimeters(long microseconds)
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
Pages: [1]