Pages: [1]   Go Down
Author Topic: control servo with conditional if  (Read 312 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged

Pages: [1]   Go Up
Jump to: