Servos stop working with Delay

//This is a program to test servos on Bluebot

#include <Servo.h>

#define LEFT_SERVO_PORT 5
#define RIGHT_SERVO_PORT 3

Servo leftServo;
Servo rightServo;

void setup(){
 leftServo.attach(LEFT_SERVO_PORT);
 rightServo.attach(RIGHT_SERVO_PORT);
}

void loop(){
 leftServo.write(0);
 rightServo.write(179);
 delay(1000);
 rightServo.write(179);
 leftServo.write(0);
 delay(1000);
}

The second batch of servo writes doesn't work the servos just twitch. I'm using a Uno with the latest version of the IDE on Ubuntu.

So, take out the delays, learn how to use blink without delay. Easy fiix.

Another example of why I hate that many books over-use delay().

@crossroads + polymorph - While you are of course right to say "blink without delay" a closer look at the code is in order

 leftServo.write(0);
 rightServo.write(179);
 delay(1000);
 rightServo.write(179);
 leftServo.write(0);

The op has just swapped the order of the writes and not the values writen!

Mark

Um, yeah, that too 8)

:blush: Um... sure, I knew that....