Go Down

Topic: servo help (Read 803 times) previous topic - next topic

pittom

Hi,I need to move 4 servo with a uno

example
-servo 1 on pin ? goes from pos 0 to 24 when input pin 3 goes high and servio 1 goes back to pos 0 when pin 3 goes low

-servo 2,3,4  output will all have there own input high/low pin

any help would be great
thanks

johnwasser

Code: [Select]

void loop()
   {
if (digitalRead(3))
    servo1.write(24);
else
    servo1.write(0);

if (digitalRead(x))
    servo2.write(24);
else
    servo2.write(0);

if (digitalRead(y))
    servo3.write(24);
else
    servo3.write(0);

if (digitalRead(z))
    servo4.write(24);
else
    servo4.write(0);
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

pittom

i can't get the servo and input pin setup,how would i do it? every thing i tried did not work

zoomkat

Simple button servo setup.

Code: [Select]

//zoomkat servo button test 7-30-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy