I also have an other code where they work at the same time but then they are not sweeping, but just setting the position of the servo.
Best code for me is if i could make a code where i had both sweeping where the poti controls the speed and the if i pushed a button it would change to this code and then the poti just controls the position. sorry if there is to many questions the most important is the one in the post before but I just like to put the ideas up there ![]()
Thx again
// Modification of the Servo Example Knob
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott http://people.interaction-ivrea.it/m.rinott
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo myservo1; // create servo object to control a servo
Servo myservo2; // create servo object to control a servo
int potpin3 = 3; // analog pin used to connect the potentiometer
int potpin4 = 4; // analog pin used to connect the potentiometer
int potpin5 = 5; // analog pin used to connect the potentiometer
int val3; // variable to read the value from the analog pin
int val4; // variable to read the value from the analog pin
int val5; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10); // attaches the servo on pin 9 to the servo object
myservo2.attach(11); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val3 = analogRead(potpin3); // reads the value of the potentiometer (value between 0 and 1023)
val3 = map(val3, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val3); // sets the servo position according to the scaled value
val4 = analogRead(potpin4); // reads the value of the potentiometer (value between 0 and 1023)
val4 = map(val4, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val4);
val5 = analogRead(potpin5); // reads the value of the potentiometer (value between 0 and 1023)
val5 = map(val5, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo2.write(val5);
delay(15); // waits for the servo to get there
}