Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
// Sweep// by BARRAGAN <http://barraganstudio.com> #include <Servo.h> Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for(pos = 0; pos < 180; pos += 5) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(25); // waits 15ms for the servo to reach the position } for(pos = 180; pos>=1; pos-=5) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(25); // waits 15ms for the servo to reach the position } }
I just got a roboduino and I found out only pins 9 and 10 can run servos. I have more than 2 I need to plugin. 3,5,6, and 11 say PWM but do not work.
#include <SoftwareServo.h> SoftwareServo myservo; // create servo object to control a servo int potpin = 0; // analog pin used to connect the potentiometerint val; // variable to read the value from the analog pin void setup() { myservo.attach(3); // attaches the servo on pin 3 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); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there SoftwareServo::refresh();}
#include <SoftwareServo.h>SoftwareServo servo1;int pos = 0;void setup(){ servo1.attach(5);}void loop(){ for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree servo1.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 { servo1.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }
Although the new softwareServo library can control all the pins , ONLY PLUG IN YOUR SERVOS TO THE PWM PINS!This is because only the PWM pins are unregulated power pins, the others are all regulated.
Quote from: airman00 on March 19, 2009, 07:08:55 PMAlthough the new softwareServo library can control all the pins , ONLY PLUG IN YOUR SERVOS TO THE PWM PINS!This is because only the PWM pins are unregulated power pins, the others are all regulated.Servos will work on the other pins, they just go slower because they don't get as much voltage.
I know PWM is for servos, and servos should not go else where. I like the servo.h library better, it is more simple, like I can do for(pos > 180) and stuff, this one I have tons of timing.I want it set up like this. Is this possible?
Servo servo1;
Servo::refresh();