Pages: [1]   Go Down
Author Topic: Problem making a Servo library  (Read 360 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm writing a library to make a two-wheeled, two-servo robot move forwards.  Dull, I know, but you've got to start somewhere.

When I run a sketch of the idea, the robot moves forwards.  The library compiles and uploads, but it makes the right servo moves more slowly than the left, so the robot just spins around.  

Any ideas what's going on?  There are a lot of posts about using libraries from within libraries in this section, and I wonder if it's related to that.

Here's the sketch that works:

#include <Servo.h>

Servo left;
Servo right;

void setup(){

void loop(){

Here's the library code that doesn't work:

// Move.h:
#ifndef Move_h
#define Move_h

#include <WProgram.h>
#include <Servo.h>

class Move
     Move(int leftPin, int rightPin);
     void fd();
     Servo leftServo;
     Servo rightServo;


// Move.cpp:
#include "Move.h"

Move::Move(int leftPin, int rightPin) {
void Move::fd(){

// Sketch1.pde:
#include <Servo.h>
#include <Move.h>

Move move(9, 10);

void setup(){

void loop(){

Pages: [1]   Go Up
Jump to: