arduino code

im working on the ankle servos, so im just using the example sweep, an i have them zeroed at 90 deg. I can get it from 90 to 180 an back but i cant get it to go 90 - 0.   




#include <Servo.h> 


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



int pos = 90;   


void setup() 




void loop() 

  for(pos = 90; pos > 45; pos += 1)  // goes from 0 degrees to 180 degrees 

  {                                  // in steps of 1 degree 




  for(pos = 45; pos <=90; pos-=1)    








For loops

We have some issues with your numbers in the for loops. The first for-loop as you have it written now is:

Start at 90; as long as pos is greater than 45 then; increase by one each loop

This loop will be skipped in the fact that 90 is already bigger than 45. The reverse is the case for your second loop. As it just-so-happens, I have something that might help.

This is a tutorial I did for the new LMR Tadpole bot, but it covers servos and for-loops. It should clear up a lot.