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.
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.
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.