ok sorry. Not sure how I missed that but every time I read up on the comments I feel like I’m trying to drink from a fire hydrant.i previously mentioned it in post #22
thamls again
ok sorry. Not sure how I missed that but every time I read up on the comments I feel like I’m trying to drink from a fire hydrant.i previously mentioned it in post #22
Hi Ron,This came up before and I recall the thread. Here it is. I know this stuff can be a little confusing and I am well aware as we age things do not sink in quite as quick as they once did. Believe me you can get this done with an Arduino Uno.
Here is an example:
Try running that code and I am willing to bet all 3 servos will respond about equally, any lag between servo 1 & 3 won't be noticeable. All of this was covered back in April the same way. All the above code does is run the servos 180 degrees and back over and over again. Written for an Arduino Uno and originally for a single servo. I do not have three servos to actually try it out and if anyone sees a problem with it feel free to critique it.Code:#include <Servo.h> Servo myservo1; // create servo object to control a servo1 Servo myservo2; // create servo object to control a servo2 Servo myservo3; // create servo object to control a servo3 // twelve servo objects can be created on most boards but here we use only 3 servo motors. int pos1 = 0; // variable to store the servo1 position int pos2 = 0; // variable to store the servo2 position int pos3 = 0 // variable to store the servo3 position void setup() { myservo1.attach(9); // attaches the servo1 on pin 9 to the servo object myservo2.attach(10); // attaches the servo2 on pin 10 to the servo object myservo1.attach(11); // attaches the servo3 on pin 11 to the servo object } void loop() { for (pos1 = 0; pos1 <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos1); // tell servo to go to position in variable 'pos1' for (pos2 = 0; pos2 <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos2); // tell servo to go to position in variable 'pos2' for (pos3 = 0; pos3 <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos3); // tell servo to go to position in variable 'pos3' delay(15); // waits 15ms for the servo to reach the position } for (pos1 = 180; pos1 >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos1); // tell servo to go to position in variable 'pos1' for (pos2 = 180; pos2 >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos2); // tell servo to go to position in variable 'pos2' for (pos3 = 180; pos3 >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos3); // tell servo to go to position in variable 'pos3' delay(15); // waits 15ms for the servo to reach the position } }
Ron
I missed it too. Actually I am tempted to swear it wasn't there. Posts with videos tend to jump outok sorry. Not sure how I missed that but every time I read up on the comments I feel like I’m trying to drink from a fire hydrant.
thamls again
That is pretty cool.Check out the Halloween-L group on Facebook. You’ll find many projects animating skeletons or other props using an Arduino and RC servos.
The Arduino and Adafruit shield is an EXCELLENT choice for your project. You just need to read more about how people are using it in Halloween props.
I’ve mentioned my project several times, so I thought I’d post a video. This animatronic uses an Arduino and 11 RC servos. And in addition to the movement, it controls an MP3 shield to make the animatronic talk. And the Arduino has an Ethernet shield so multiple characters collaborate and have conversations, sing in multipart harmony, etc...
So I’m confident an Arduino will work for you.
I had to stiffen the risers to eliminate the wobbles.That is pretty cool.
Ron
#include <Servo.h>
Servo myservo1; // create servo object to control a servo1
Servo myservo2; // create servo object to control a servo2
Servo myservo3; // create servo object to control a servo3
// twelve servo objects can be created on most boards but here we use only 3 servo motors.
int pos1 = 0; // variable to store the servo1 position
int pos2 = 0; // variable to store the servo2 position
int pos3 = 0; // variable to store the servo3 position
void setup() {
myservo1.attach(9); // attaches the servo1 on pin 9 to the servo object
myservo2.attach(10); // attaches the servo2 on pin 10 to the servo object
myservo3.attach(11); // attaches the servo3 on pin 11 to the servo object
}
void loop() {
for (pos1 = 0; pos1 <= 180; pos1 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo1.write(pos1); // tell servo to go to position in variable 'pos1'
}
for (pos2 = 0; pos2 <= 180; pos2 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo1.write(pos2); // tell servo to go to position in variable 'pos2'
}
for (pos3 = 0; pos3 <= 180; pos3 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo3.write(pos3); // tell servo to go to position in variable 'pos3'
}
delay(15); // waits 15ms for the servos to reach the position
for (pos1 = 180; pos1 >= 0; pos1 -= 1) { // goes from 180 degrees to 0 degrees
myservo1.write(pos1); // tell servo to go to position in variable 'pos1'
}
for (pos2 = 180; pos2 >= 0; pos2 -= 1) { // goes from 180 degrees to 0 degrees
myservo2.write(pos2); // tell servo to go to position in variable 'pos2'
}
for (pos3 = 180; pos3 >= 0; pos3 -= 1) { // goes from 180 degrees to 0 degrees
myservo3.write(pos3); // tell servo to go to position in variable 'pos3'
}
delay(15); // waits 15ms for the servos to reach the position
}
OK, my bad on my code sample. I have it fixed and it runs on an Arduino Uno. I took the time to look at it on a scope. The code is pretty basic and I used plenty of remarks along the way trying to explain what is going on.
RonCode:#include <Servo.h> Servo myservo1; // create servo object to control a servo1 Servo myservo2; // create servo object to control a servo2 Servo myservo3; // create servo object to control a servo3 // twelve servo objects can be created on most boards but here we use only 3 servo motors. int pos1 = 0; // variable to store the servo1 position int pos2 = 0; // variable to store the servo2 position int pos3 = 0; // variable to store the servo3 position void setup() { myservo1.attach(9); // attaches the servo1 on pin 9 to the servo object myservo2.attach(10); // attaches the servo2 on pin 10 to the servo object myservo3.attach(11); // attaches the servo3 on pin 11 to the servo object } void loop() { for (pos1 = 0; pos1 <= 180; pos1 += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo1.write(pos1); // tell servo to go to position in variable 'pos1' } for (pos2 = 0; pos2 <= 180; pos2 += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo1.write(pos2); // tell servo to go to position in variable 'pos2' } for (pos3 = 0; pos3 <= 180; pos3 += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo3.write(pos3); // tell servo to go to position in variable 'pos3' } delay(15); // waits 15ms for the servos to reach the position for (pos1 = 180; pos1 >= 0; pos1 -= 1) { // goes from 180 degrees to 0 degrees myservo1.write(pos1); // tell servo to go to position in variable 'pos1' } for (pos2 = 180; pos2 >= 0; pos2 -= 1) { // goes from 180 degrees to 0 degrees myservo2.write(pos2); // tell servo to go to position in variable 'pos2' } for (pos3 = 180; pos3 >= 0; pos3 -= 1) { // goes from 180 degrees to 0 degrees myservo3.write(pos3); // tell servo to go to position in variable 'pos3' } delay(15); // waits 15ms for the servos to reach the position }
Hi Ron,Ron,
Your the best. Thank you so much!!!
hi. Yes I did. Just a little over 5vdcHave you measured supply voltage at this moment when servos go shatter?
they chatter immediately when I upload the programhi. Yes I did. Just a little over 5vdc
same voltage with the program that works fine. Weird. Different Arduino, different servos. Same resultthey chatter immediately when I upload the program
for (pos1 = 180; pos1 >= 0; pos1 -= 1) { // goes from 180 degrees to 0 degrees
myservo1.write(pos1); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
Exactly why I’m so blown away. Could only happen to me lol.You can try trebla's suggestion. I can't imagine why it ran fine and then began chattering? It's just a simple routine which runs over and over again so why it would suddenly burp I am not sure. I only have one little servo to experiment with so I just checked things using a scope and ran it a few min. That said it did pretty much demonstrate that any lag between lines is negligible. The Arduino Uno is used in animatronic projects frequently and it or any similar uC should do fine for your intended application.
Ron
One of the first things I suspected was servos not getting enough current so I tried powering it from a 12 volt power supply. But again, logically, why are the servos working perfectly from an older program I had used before?Are you powering servos from Arduino? Servos tend to draw lot of current. It is good idea to power servos from different 5V and 2-3 A power source.
Looking at my 12 volt power supply, it’s only delivering 1000 ma. (1 amp).Are you powering servos from Arduino? Servos tend to draw lot of current. It is good idea to power servos from different 5V and 2-3 A power source.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
M | RTOS uC / Micro-processor | Microcontrollers | 9 | |
A | how micro-controller or processor boot ? | Microcontrollers | 1 | |
M | Micro Processor | General Electronics Chat | 13 | |
Difference between micro processor and Micro controller | General Electronics Chat | 9 | ||
B | micro processor | Microcontrollers | 7 |