'_'

sweep_motor_채찍질 본문

자료용

sweep_motor_채찍질

YISUP 2017. 7. 9. 12:13


// Sweep

// by BARRAGAN <http://barraganstudio.com> 

// This example code is in the public domain.



#include <Servo.h> 

 

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

                // a maximum of eight servo objects can be created 

 

int pos = 0;    // variable to store the servo position 


 

void setup() 

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

  myservo.write(180);  

  delay(5000);

 

 

void loop() 

    myservo.write(160);              // tell servo to go to position in variable 'pos' 

                                     // waits 15ms for the servo to reach the position 

   


  delay(random(10000,35000));

  for(pos = 170; pos >= 10; pos -= 1)  // goes from 0 degrees to 180 degrees 

  {                                  // in steps of 1 degree 

    myservo.write(pos);              // tell servo to go to position in variable 'pos' 

    delay(10);                       // waits 15ms for the servo to reach the position 

  } 


  delay(400);