Go Down

Topic: Motor and Ping sensor seem incompatible? (Read 619 times) previous topic - next topic

scyth3s

Jun 27, 2012, 10:23 pm Last Edit: Jun 27, 2012, 10:30 pm by scyth3s Reason: 1
So I've got this project built off of a MindsI robotics kit. At its bare minimum, I have one servo motor connected into slot 11 of the sensor shield, and one Parallax Ping sensor connected into slot 7.

With this code,
Code: [Select]

#include <MINDSi.h>
#include <Servo.h>

Servo drive, steer;

void setup()
{
 Serial.begin(9600);
 
 //steer.attach(11);
 //steer.write(90);
 
 delay(2000);
}

void loop()
{
 int ping = getPing(7);
 Serial.println(ping);
}


The ping sensor funtions perfectly, and outputs roughly accurate distances. As soon as I uncomment one line,

Code: [Select]
steer.attach(11);

the ping sensor ceases to work, and outputs a LOT of zeroes, followed by one or two seemingly arbitrary distances every minute.

It is not this exact sensor shield, but it is very similar in structure, just mildly different layout. http://www.amazon.com/SainSmart-Sensor-Digital-Arduino-Duemilanove/dp/B006TQ314G/ref=sr_1_1?ie=UTF8&qid=1340828476&sr=8-1&keywords=arduino+sensor+shield

Does anyone have a clue why this should happen?

You would need information about the exact shield you're using to figure this out, or find out that it's not possible.  Why not just connect the sensor and servo directly to the Arduino without the shield?

Tim
Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

scyth3s

Why not just connect the sensor and servo directly to the Arduino without the shield?

Tim


It's mounted on the chassis of an RC car that I've constructed, and doing it that way would mean I have to use a breadboard because more than two things need a 5v rail. The breadboard takes up extra space and requires fastening down, whereas the shield fits compactly right on top of the Arduino. Combine that with the fact that a friend is currently borrowing my breadboard, and that I'd have to wait til tomorrow to use it, and I'm basically left with the shield option-- or making my own rails. How hard can that be?

I'm trying to find the exact sensor shield that I have, but I can't find so much as a brand name or other identifying title on it! -_-


Why not just connect the sensor and servo directly to the Arduino without the shield?

Tim


It's mounted on the chassis of an RC car that I've constructed, and doing it that way would mean I have to use a breadboard because more than two things need a 5v rail. The breadboard takes up extra space and requires fastening down, whereas the shield fits compactly right on top of the Arduino. Combine that with the fact that a friend is currently borrowing my breadboard, and that I'd have to wait til tomorrow to use it, and I'm basically left with the shield option-- or making my own rails. How hard can that be?

I'm trying to find the exact sensor shield that I have, but I can't find so much as a brand name or other identifying title on it! -_-


If you're having a problem as simple as this, you should taken to a breadboard level, it could be as simple as the ports you're using share the same Arduino pins.  Have you tried using different ports on the shield?

Tim
Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Go Up