Controlling continuous rotation servo's through own library

Hello guys,

I tried to create a library to control two servo’s who function as wheels, the wheels are for BOE bots. I don’t get errors compiling, but it wont control the servo’s. Here is the test script I’m trying to use:

#include <Servo.h>
#include "Move.h"

Move test(11,12);
  

void setup()
{
  // put your setup code here, to run once:
  
}

void loop()
{
  // put your main code here, to run repeatedly:
  test.backwards();
  delay(1000);
  test.forward();
  delay(1000);
}

Here is my header file:

/*
Jorg de Bont
2013
Move functions for arduino servo full rotations
*/
#ifndef Move_h
#define Move_h
#include <Servo.h>
#include <Arduino.h>


class Move
{
     public:
        Move(int leftMotor, int rightMotor);
        void standStill();
        void forward();
        void backwards();
        void softForward();
        void softBackwards();
        void leftAs();
        void rightAs();
        void goLeft();
        void goRight();

    private:
        int Lstreak;
        int Rstreak;
        int L;
        int R;
        Servo left;
        Servo right;

};


#endif

And here my .cpp:

#include <Arduino.h>
#include <Servo.h>
#include <Move.h>

Move::Move(int leftMotor, int rightMotor)
{
    L = leftMotor;
    R = rightMotor;
    left.attach(L);
    right.attach(R);
    Lstreak = 0;
    Rstreak = 0;
}
void Move::standStill()
{
    left.attach(L);
    right.attach(R);
    left.write(1500);
    right.write(1500);
}

void Move::forward()
{
    left.attach(L);
    right.attach(R);
    left.write(1700);
    right.write(1300);
}

void Move::backwards()
{
    left.attach(L);
    right.attach(R);
    left.write(1300);
    right.write(1700);
}

void Move::softForward()
{
    left.write(1550);
    right.write(1450);
}

void Move::softBackwards()
{
    left.write(1450);
    right.write(1550);
}

void Move::leftAs()
{
    left.write(1450);
    right.write(1450);
}

void Move::rightAs()
{
    left.write(1550);
    right.write(1550);
}

void Move::goRight()
{
    Lstreak = 0;
    if (Rstreak <3){
        left.write(1700);
        right.write(1535);
        Rstreak ++;
    }
    else{
        left.write(1565);
        right.write(1525);
    }
    delay(5);
}

void Move::goLeft()
{
    Rstreak = 0;
    if (Lstreak < 3){
        left.write(1535);//beetje sturen
        right.write(1300);
        Lstreak ++;
    }
    else{
        left.write(1475);//Kapot hard sturen
        right.write(1425);
    }
    delay(5);
}

It loads but won’t control the servo’s. I wonder if someone could point out my mistakes.

Sorry for my bad english it isn’t my mother tongue.

Greetings Jazula

Sorry, but I'm lazy and you have posted a lot of code.

Have you managed to get what you want to happen without writing a library?

...R

What do you want to do that needs a new servo library?

Hello,

Yes I managed to get it work without my libary. the reason I want a library is because this way I only have to command the servo's to go forward, instead of writing a value to each different servo. This way I can use this library for every BOE-bot we own.

Greetings Jazula

You could keep your servo code in a separate .ino file in the same directory as your main sketch. That way it would be easy to copy to a new project.

I have never tried to make my code into a library so I can't help with the process for doing that.

...R