Project 05 - Mood Cue - Servo Trembling

Hi All,

The Problem:
So following The Arduino Starter Kit, Project 05 - Mood Cue. I have the circuit connected up and used the example code from the IDE, however the motor just trambles in place very weakly oscillating maybe a degree or two.

Details:
The TX light is on, RX light is off, and LED light looks dimly light, which is odd because I don't think it's connected up. An additional point is pressing on either terminus of the A0 - Potentiometer wire increases how vigourous the trembling is, removing the pressure returns it back to the weak tremble. This makes me think the wire is loose, but it's in the socket pretty solidly. The servo tends to do a more definite turn the first time it is connected or disconnected, before returning to trembling.

Circuit:



Code:

// include the Servo library
#include <Servo.h>

Servo myServo;  // create a servo object

int const potPin = A0; // analog pin used to connect the potentiometer
int potVal;  // variable to read the value from the analog pin
int angle;   // variable to hold the angle for the servo motor

void setup() {
  myServo.attach(9); // attaches the servo on pin 9 to the servo object
  Serial.begin(9600); // open a serial connection to your computer
}

void loop() {
  potVal = analogRead(potPin); // read the value of the potentiometer
  // print out the value to the Serial Monitor
  Serial.print("potVal: ");
  Serial.print(potVal);

  // scale the numbers from the pot
  angle = map(potVal, 0, 1023, 0, 179);

  // print out the angle for the servo motor
  Serial.print(", angle: ");
  Serial.println(angle);

  // set the servo position
  myServo.write(angle);

  // wait for the servo to get there
  delay(15);
}

Servos pull a lot of current - more than the Arduino can provide.

Breadboards have tiny traces and can't withstand high currents.

So you have a double whammy: a device trying to pull too much power from a source that can't provide it, through a connection that can't handle it.

That twitching you see is another clue that the servo is underpowered.

It is true that you will see tutorials that suggest that you can run a servo connected to an Arduino, and you can, maybe, if the servo has no load. For best results though, the servo needs its own power, the Arduino just controls it.

I see. Thanks for letting me know. So nominally is the circuit and code correct?
How would I go about modifying the circuit to accommodate a power source? A transistor with the potentiometer on the drain, the battery on the source, and the yellow wire on row 17 as the gate?

It's weird Arduino's own starter kit shouldn't meet the specs of their own hardware though - would I not expect everyone to be suffering this same problem with this project (t's from the tutorials)? (It is this tutorial)

The simplest circuit for servos is power and ground from a suitable supply to the servo, control wire to Arduino, connect the grounds.

Then you can run the sweep example to test.

Okay, I've added a power source, and coupled the grounds. I'm running the code the same as before. The lights and motor are as before.

I'm not too sure what the sweep is, I don't see any example folder with it in, if it is a type of sketch.

Does this circuit look capable of running the servo more correctly?

No - that battery isn't powerful enough and it's the wrong voltage. Four AAs is a more usual configuration if you want to run a hobby servo of a battery.

Sweep is a servo example that comes with the IDE.

Ah, there I might be stuck - the starter kit only came with a battery clip for a 9V battery. Seems odd they would miss such a vital component of the starter kit of their own product. Is there no other way to run the servo properly?

You could go back to powering the servo from the Arduino. Directly for preference, rather than through the breadboard and try sweep.

Okay, that works... the servo is slowly sweeping out a 180 degree arc, then turns back the other direction and repeats. So is the problem here the breadboard itself?

Eventually I'd like to turn this project into the ability to move a plastic arm up and down from a remote input (using LabView if it matters), and was going to use this tutorial as the basis for that. Do you think Arduino is not suitable for this task?

Try it using the breadboard perhaps.

Be aware that many servos can't manage the whole 180 degrees. It occurs to me that the original problem may have been that the pot was asking for a position that the servo couldn't manage.

Nonetheless, if you want to make real project, I still suggest that you get better power for it.

Okay, with just the servo, (i.e. no capacitors) it's working just as plugged into the UNO alone. So I'm guessing the problem is either the capacitors or the potentiometer the analog input? my money is the potentiometer. That said, the servo does appear to be able to do the full 180 arc, and that potentiometer is ask 179.

At the moment it does just rotate back and forth, how would I control it to stop at one end or the other - i.e. take an input to move the servo to the far end of it's arc, and then input again to move it back to the other end of the arc?

Do the capacitors / analog input that are now out of the circuit make any real difference?

Agreed, it sounds like power would be a good idea, but baby steps, I'll get this thing working first

If you go back to your original code with the pot wired up, what does the serial monitor say the angle requested is? Does it wobble?

Maybe a longer delay would help keep things stable.

The angle changes slightly... it oscillates about 58-60 region

Maybe that oscillation is actually the original problem.

I have done this exact project with this exact problem.

The potentiometer isn't connected well, the middle pin is on the other side of the breadboard and the yellow wire doesn't connect.
In the book it's connected to one side, but it's not possible.

Edit: I use the power from the Arduino pins, no extra power source connected.
Same servo, 180 degrees. Everything works perfectly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.