User Tools

Site Tools


servo-180-test

Warning: Use of undefined constant PREG_PATTERN_VALID_LANGUAGE - assumed 'PREG_PATTERN_VALID_LANGUAGE' (this will throw an Error in a future version of PHP) in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

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