problems with code --> ServoTimeTimer1

I have a problem with some code.
As I already described here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1195136418/0#0.
I try to build a small robot. Currently I’m butting all bits together. Now I’m struggling with some code I tried.

I want to control two servos with the ServoTimeTimer1 from here http://www.arduino.cc/playground/ComponentLib/Servotimetimer1.

Now my problem (please be patient I’m newbie :-/). Here the code I have:


#include <ServoTimeTimer1.h>

#define servoPin1 9
#define servoPin2 10
#define potPin1 0
#define potPin2 1

ServoTimeTimer1 servo1;
ServoTimeTimer1 servo2;

int myPot1 = 0;
int myPot2 = 0;
int ledPin = 13;                // LED connected to digital pin 13

void setup ()
{
  servo1.attach(servoPin1);
  servo2.attach(servoPin2);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void ledBlink()
{
  //BLINK1
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  //BLINK2
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

void loop()
{
    for (myPot1=0; myPot1<=180;  myPot++)
    {
      servo1.write((myPot1*2)+500);
      ledBlink();
    }
    for (myPot2=0; myPot2<=180;  myPot2++)
    {
      servo2.write((myPot2*2)+500);
      ledBlink();
    }
    for (myPot1=180; myPot1>=0;  myPot1++)
    {
      servo1.write((myPot1*2)+500);
      ledBlink();
    }
    for (myPot2=180; myPot2>=0;  myPot2++)
    {
      servo2.write((myPot2*2)+500);
      ledBlink();
    }
}

Here my problem:

 In function 'void loop()':
error: 'myPot' was not declared in this scope

Can you please help? :-?

Greg

the clue to the problem is in the error message: “myPot was not declared…”

for (myPot1=0; myPot1<=180;  myPot++)

in this for loop you are incrementing a variable called myPot when you intend myPot1.

BTW, I think servo2.write() expects a value between 500 and 2500, not an angle. So you may want to do something like:

for (myPot1=500; myPot1 <= 2500; myPot1++)

in fact, many servos expect a range between 1000 and 2000 microseconds so I would start off with that and increase the range after verifying that the servos don’t hit the end stops.

:o
I'm stupid

:frowning:

Thanks for your hint!

Greg