User Tools

Site Tools


servo-180-test

This code turns the servo between 0 and 180 and then back

// servo test 180 > 0 > 180

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
int val;   // variable to write to the servo 
 
void setup() 
{ 
  myservo.attach(11,600,2100);  // attaches the servo on pin 11 to the servo object 
  Serial.begin(115200);
} 
 
void loop() 
{  
  
   for (val=0; val < 179; val ++) {
     myservo.write(val);
     delay(10);
   }
  for (val=179; val > 0; val --) {
     myservo.write(val);
     delay(10);
   }  
} 
servo-180-test.txt · Last modified: 2012/10/06 13:40 by 85.218.109.130