Back to Parent

#include <Servo.h>

Servo myservo;
Servo myservo2; // create servo object to control a servo


int val; 
int val2;


void setup() {
  myservo.attach(9);  
  myservo2.attach(10);
   

}

void loop() {

/*
  val = map(val, 0, 1023, 90, 180);
  val2 = map(val, 0, 1023, 90,0);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);  
  myservo2.write(val2);               // sets the servo position according to the scaled value
  delay(2000);                        // waits for the servo to get there
*/


  for (int i = 140; i < 170; i++) {
    myservo.write(i);
    myservo2.write(180-i);
    delay(20);
  }

  for (int i = 170; i >= 140 ; i--) {
    myservo.write(i);
    myservo2.write(180-i);
    delay(20);
  }

}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0