Hey Im a noob I used an hs-55 servo (smaller servo) and an airtronics. (larger servo) plugged the into pins 9 and 10 and tried to make it so the airtronics servo could be operated by the potentiometer while the hs-55 servo operated on its own. The hs-55 started smoking and I dont know why, if its thecoding or how i wired it or what.
#include <Servo.h>
Servo myservo;
Servo myservo2;// create servo object to control a servo
int pos = 0;// postion of servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9);
myservo2.attach(10); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val);
delay(15);
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
{
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{ myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
Must be the wiring, I have tried to abuse a servo by connecting the signal wire to different voltages, negative, positive, and so... Only thing that broke it, was to wire it wrong, and give it wrong voltages...
Must be the wiring, I have tried to abuse a servo by connecting the signal wire to different voltages, negative, positive, and so... Only thing that broke it, was to wire it wrong, and give it wrong voltages...
THE ANSWER
never mind thats not the problem its when i turn the poentiomer the servo stops and starts smoking this sucks
what are you trying to ask your statement dosent make sense
I have a Board that can connect to the top of the arduino for servos to easily be able to plug in. I have one servo going to pin 10 and the other to pin 9. When I run the code my first servo will do the sweeping motion but when I want to operate the second servo by turning the potentiometer, the sweeping servo stops and gets hot and smokes while the servo bbeing operated with the pot lags or doesnt even work. Every thing is wired fine.
The reason the servo on the pot stops, is because of your "for" loops inside the loop(), it will run through them first, before moving further and then back to checking the pot again.
And as I said before, the code CAN NOT break your servo's like this. It is the way they are connected.
Just tested this code on some cheap servo's, and they both do what the code tells them to do.
First servo moves to a position determined bu the pot, the other then makes a sweep, and the first then again moves to what the pot tells it to...
#include <Servo.h>
Servo myservo;
Servo myservo2;// create servo object to control a servo
int pos;// postion of servo
int potpin = 0; // analog pin used to connect the potentiometer
void setup()
{
myservo.attach(8);
myservo2.attach(10);
}
void loop()
{
myservo.write(map(analogRead(potpin), 0, 1023, 0, 179));
delay(15);
for(pos = 0; pos < 180; pos++) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos >= 1; pos--) // goes from 180 degrees to 0 degrees
{
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
This is your code, just cleaned up a bit. When inside the IDE use CTRL+T to auto format the code, makes it a lot easier to keep the overview of it.
Okay, first off sorry im stubborn. You were correct my connections bad. It works and I now know that you cant hurt the arduino with code . thanks so much. Do you mind telling me now how to make the sweeping servo stay at an initial position and rotate 90 degrees then back to its original state after turning the potentiometer servo a certain value? so i twist the pot and when i turn it depending on a certain value it triggers the other servo to move.?
what can break your servo is the build-in stop to prevent it from turning further than (say) 90deg.
if your software manages to command it to turn further, it stalls the motor trying to move past the stop. a stalled motor is basically a short-circuit....
the problem is that the pulsewidth belonging to 0 and 180 deg
might vary per servo, so that what the servo.h thinks is 180 might be interpreted by the actual servo as 185 deg.
try mapping the value range conservatively, e.g. 10 to 170
instead of 0-180.
to see that stop i'm talking about google for "servo hack" or "servo continuous rotation".