websitetemplate.org

Hjem > Arduino Duemilanove > Servo

Servo

Så kom der pakke fra Kinastand.

Tre små kinesere.




Det tog 8 dag og kostede 41,40 kr for alle tre.



Det sjoveste er at de virker.
Jeg måtte dog skifte min PWM kode ud med SERVO Librarie i ver 1.0.5.
Jeg har lige strikket lidt videre på eksempel koden.

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.

#include <Servo.h>
 
Servo myservo9;  // create servo object to control a servo
Servo myservo10;  // create servo object to control a servo
Servo myservo11;  // 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()
{
  myservo9.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo10.attach(10);  // attaches the servo on pin 9 to the servo object
  myservo11.attach(11);  // attaches the servo on pin 9 to the servo object

  myservo9.writeMicroseconds(1500);  // set servo to mid-point
  myservo10.writeMicroseconds(1500);  // set servo to mid-point
  myservo11.writeMicroseconds(1500);  // set servo to mid-point
  delay( 1000 ); 
}
 
void loop()
{
  for(pos = 10; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo9.write(pos);              // tell servo to go to position in variable 'pos'
    myservo10.write(pos);              // tell servo to go to position in variable 'pos'
    myservo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(1000);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=10; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo9.write(pos);              // tell servo to go to position in variable 'pos'
    myservo10.write(pos);              // tell servo to go to position in variable 'pos'
    myservo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(1000);                       // waits 15ms for the servo to reach the position
  }
}

Powered By CMSimple.dk - Design By OZ5HZ Finn Johansen