Very new to this but need advice

I am trying to run 3 servos with a Uno. They are to have three positions each 0, 90, 180. What I am trying to get them to do is operate at the same time but maneuver between 0, 90, 180 randomly. Any advice would greatly be appreciated

Are you powering the servos with the uno? Do you have them connected to PWM pins? Are you using the Servo library? Do you have any code to try? Are the servo grounds connected to uno?

Shanedaily:
I am trying to run 3 servos with a Uno. They are to have three positions each 0, 90, 180. What I am trying to get them to do is operate at the same time but maneuver between 0, 90, 180 randomly. Any advice would greatly be appreciated

What have you tried so far?

Hi,
Power issues:

  • What servos? Micro? Big??
  • What Servo power is available?
  • USB only probably will not work unless MicroServos and careful to move only one at a time.
  • Best is separate 5V supply.

new too but this may help

int servAngle = random(1,4); // will return random number between 1 and 3

then you can translate to a servo value using a "case" statement or "if" 1 = 0, 2 = 90, 3= 180...should be plenty of examples of that in the docs here.

then (assuming you are using the PWM pins with the ~ next to them) you could also randomly choose a pin number from that set with the same approach so you it would be really random choosing a random rotation for random pin output each cycle.

you'll need to start simple though... just try moving one servo with one pin to start then the above random routine once you know it is working.

running them at the same time - someone else might be able to comment...not sure if you can really run them in parallel easily but you might be able to make it appear that way with a cycle- that part is beyond my noob level.

they can appear to run at the same time. as soon as you send analogWrite the servo will start to move and the next line of code will execute. if that is a Write to another servo that one will start to move. the time between the two moving will appear simultaneous. in other words the analogWrite is not blocking. there is no waiting for the servo to reach its final position unless you code or compensate for it.

as soon as you send analogWrite the servo will start to move

If you don't want to waste power and overheat your servo, don't use analogWrite, use the Servo library, and use its write method instead.

If you don't want to waste power and overheat your servo, don't use analogWrite, use the Servo library, and use its write method instead.

So right. Sorry. AnalogWrite wholly inapproptiate for servos.