Facebook
From Thanat, 1 Month ago, written in Actionscript.
This paste is a reply to servo model from Thanat - view diff
Embed
Download Paste or View Raw
Hits: 42
  1. #include <Servo.h>
  2. int pin = 10;
  3. unsigned long duration;
  4. int rc = 0;
  5. Servo servo1; // top left
  6. Servo servo2; // bottom left
  7. Servo servo3; // top right
  8. Servo servo4; // bottom right
  9. void setup() {
  10.   Serial.begin(9600);
  11.   pinMode(pin, INPUT);
  12.   //pinMode(6,OUTPUT);
  13.    servo1.attach(6);
  14.    servo2.attach(7);
  15.    servo3.attach(8);
  16.    servo4.attach(9);
  17. }
  18.  
  19. void loop() {
  20.   duration = pulseIn(pin, HIGH);
  21.   if(duration <1350)
  22.   {
  23.     servo1.write(85);
  24.     servo2.write(72);
  25.     servo3.write(77);
  26.     servo4.write(85);
  27.   }
  28.   else if (duration >1350 and duration <1550)
  29.   {
  30.        servo1.write(45);
  31.     servo2.write(117);
  32.     servo3.write(35);
  33.     servo4.write(130);
  34.   }
  35.   else
  36.   {
  37.    servo1.write(0);
  38.   servo2.write(0);
  39.   servo3.write(0);
  40.   servo4.write(0);
  41.   }
  42. }