Iclude 3rd servo

Hello guys,

who can please explain me how i can iclude a 3rd servo into the code ?

#include <Servo.h>

Servo servoLeft;          // Definiere linken Servo
Servo servoRight;         // Definiere rechten Servo

void setup() { 
  servoLeft.attach(44);  // Setzt linken Servo auf digital pin 44
  servoRight.attach(22);  // Setzt rechten Servo auf digital pin 22
} 

void loop() {            // Loop für den Bewegungstest
  forward();             // Bsp: Bewege Vorwärts
  delay(2000);           // Waete 2000 millisekunden (2 Sek)
  reverse();
  delay(2000);
  turnRight();
  delay(2000);
  turnLeft();
  delay(2000);
  stopRobot();
  delay(2000);
}

// Bewegungs Routine für Vorwärts, Rückwärts, Drehungen und STOP
void forward() {
  servoLeft.write(0);
  servoRight.write(180);
}

void reverse() {
  servoLeft.write(180);
  servoRight.write(0);
}


void turnRight() {
  servoLeft.write(180);
  servoRight.write(180);
}
void turnLeft() {
  servoLeft.write(0);
  servoRight.write(0);
}

void stopRobot() {
  servoLeft.write(90);
  servoRight.write(90);
}

thanks

Just like the other two, but with a different name and pin number

TolpuddleSartre:
Just like the other two, but with a different name and pin number

#include <Servo.h>

Servo servoLeft; // Definiere linken Servo
Servo servoRight; // Definiere rechten Servo
Servo servoUp;

void setup() {
servoLeft.attach(44); // Setzt linken Servo auf digital pin 44
servoRight.attach(22); // Setzt rechten Servo auf digital pin 22
serrvoUp.attach(30);
}

and thenm include in the void the servoUp too ?

Your first changes look o.k. After that the code you need to add will depend on what you want the servo to do.

BTW from the look of that code I don't think the first two are conventional servos. It looks more as if they are continuous servos used as drive motors though if they are the code/function names are all wrong.

Steve

slipstick:
Your first changes look o.k..

... Apart from the obvious spelling error.

AWOL:
... Apart from the obvious spelling error.

Thanks for help.

@Admin Topic can closed as solved