Pages: [1]   Go Down
Author Topic: servo help  (Read 680 times)
0 Members and 1 Guest are viewing this topic.
scranton,pa
Offline Offline
Newbie
*
Karma: 2
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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);
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

scranton,pa
Offline Offline
Newbie
*
Karma: 2
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Tesla Member
***
Karma: 143
Posts: 9577
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple button servo setup.

Code:
//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);
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: