Let's Make Robots!

arduino

whats wrong with this code?

#include <Servo.h> 

 

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

Servo servotwo;                // 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 

  servotwo.attach(8);

 

 

void loop() 

  for(pos = 0; pos < 180; pos += 1)   

  {                                  

    myservo.write(pos);              

    delay(15);                       

  } 

  for(pos = 180; pos>=1; pos-=1)    

  {                                

    myservo.write(pos);            

    delay(15);                     

  } 

  {

    for(pos = 0; pos < 180; pos += 2)

   {

     servotwo.write(pos);

     delay(15);

   }

   {

    for(pos = 180; pos>=1; pos-=1)    

   }                            

    servotwo.write(pos);           

    delay(15);                        

   } 

  }

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

thanks that works perfectly!!!!

i'm trying to run two servos of my arduino using sweep.

I was hoping to catch you in the shoutbox, but, I asked, what does the code actually do when you try running it?