Servos

Hi!
I´m trying to Control two servos with two seperate potentiometers. The probem is that when i turn them the servos doesn´t move, at all. Here´s the code:

#include <Servo.h>

Servo servo1;
Servo servo2;

int pot1 = A1;
int pot2 = A2;

int valPot1;
int valPot2;

void setup() {
  // put your setup code here, to run once:
  servo1.attach(3);
  servo2.attach(5);

}

void loop() {
  // put your main code here, to run repeatedly:

  valPot1 = analogRead(pot1);
  valPot1 = map (valPot1, 0, 1023, 0, 180); 
  servo1.write(valPot1); 
  delay(15);

  valPot2 = analogRead(pot2);
  valPot2 = map (valPot2, 0, 1023, 0, 180);
  servo2.write(valPot2);
  delay(15);

}

The code looks o.k. so the problem is with the way you have everything connected together or how it is powered.

If you post a circuit diagram showing the wiring and the types and values of the components that will probably help. But if the potentiometers are smoking then something is very wrong and the Arduino may be damaged.

Steve

If you've burnt out a potentiometer you must have connected the wiper to power or ground, instead of an analog pin...

I do not know anything about why it shut down, but those 9v smoke detector batteries are fairly useless for running servos.

They are designed to run electronics, with a very small current demand.
The motors in servos have a much larger current demand.

OP's image. See this handy image guide

Yowza! You have 9v running across your pots! I bet they got hot!

I think you should look at the wiring diagrams for the knob tutorial.

It poorly uses the arduino 5v for the servo power. Keep your separate power for the servo instead.
But it properly used the arduino 5v to run across the pot.

Hi,
Please look at this circuit diagram, note how the potentiometers are connected.

  • What are the values of your potentiometer?
  • What are the make/model of your servos?
  • What voltage are you using on your servos?
  • Please post a picture of your project so we can see your layout.
  • Do you have a DMM?

Thanks.. Tom... :slight_smile:

vinceherman:
Yowza! You have 9v running across your pots! I bet they got hot!

9 V over a 10k pot shouldn't make the pot smoke. But the swiper of the pot will pick anything between 0 V and 9 V for your Arduino pins to read. Not good to read 9 V, when the Arduino itself works on 5 V.