Go Down

Topic: control servo with conditional if (Read 411 times) previous topic - next topic

zyen

please give me the script to control servo with conditional if and stop the servo and make it on again if get the next condotional if....
like pull of valve open and close valve...


please give me the direction

Krodal

Can you explain what you have.

There is a mechanical valve ?
And you want to control it with a servo ?

Can you use an electrial valve, and control that with the Arduino ?

Do you have the servo connected ?
You need the Servo library. In the Arduino, import the Servo library.
http://arduino.cc/it/Reference/Servo
Can you make the servo to rotate to a certain position ?

Code: [Select]

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                 // a maximum of eight servo objects can be created

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  if (....)              // for example check a button.
  {
    myservo.write(0);        // for example position 0 for valve 'on'
  }
  else
  {
    myservo.write(180);    // for example position 180 for valve 'off'
  }
  delay(1000);
}


Please do reply to this post, so I know that you have read it.

Go Up