Error while verifying

Am trying to code for a motor that go forward and backward, this is my code

#define ENABLE_ARDUINO_MOTOR_DRIVER

#ifdef ENABLE_ARDUINO_MOTOR_DRIVER
#include <Arduino.h>
#define LEFT_MOTOR_INIT 1
#define RIGHT_MOTOR_INIT 3
#endif

namespace Neptune
{
class Robot
{
public:

Robot()
: leftMotor(LEFT_MOTOR_INIT), rightMotor(RIGHT_MOTOR_INIT)
{
initialize();
}

void initialize()
{

leftMotor.setSpeed(255);
rightMotor.setSpeed(255);

}

void run()
{
unsigned long currentTime = millis();
unsigned long elapsedTime = currentTime - startTime;
switch (state) {
case stateStopped:
if (elapsedTime >= 5000) {
leftMotor.setSpeed(255);
rightMotor.setSpeed(255);
state = stateRunning;
startTime = currentTime;

}
break;
case stateRunning:
if (elapsedTime >= 8000) {
leftMotor.setSpeed(0);
rightMotor.setSpeed(0);
state = stateStopped;
startTime = currentTime;

}

break;

}

}

private:
Motor leftMotor;
Motor rightMotor;
enum state_t {stateStopped, stateRunning };
state_t state;
unsigned long startTime;
};

};

Neptune::Robot robot;

void setup()
{
robot.initialize();
}

void loop()
{
robot.run();

}

When I try to verify my code I get the following errors

Main_MotorDriver:64: error: 'Motor' does not name a type
Main_MotorDriver:65: error: 'Motor' does not name a type
Main_MotorDriver.ino: In constructor 'Neptune::robot::Robot()':
Main_MotorDriver:18: error: class 'Neptune::Robot' does not have any field named 'leftMotor'
Main_MotorDriver:18: error: class 'Neptune::Robot' does not have any field named 'rightMotor'
Main_MotorDriver.ino: In member function 'void Neptune::robot::initialize()':
Main_MotorDriver:27: error: 'leftMotor' was not declared in this scope
Main_MotorDriver:28: error: 'rightMotor' was not declared in this scope
Main_MotorDriver.ino: In member function 'void Neptune::robot::run()':
Main_MotorDriver:40: error: 'leftMotor' was not declared in this scope
Main_MotorDriver:41: error: 'rightMotor' was not declared in this scope
Main_MotorDriver:49: error: 'leftMotor' was not declared in this scope
Main_MotorDriver:50: error: 'rightMotor' was not declared in this scope

Hi,
code for what controller?
where is your setup
where is your loop

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom....... :slight_smile:

Code for motor shield to control 2 DC Motors

My Loop and setup are down

am a newbie :slight_smile: so am not so familiar with the terms I wrote this code with a help from an online source

this is the website "http://blog.miguelgrinberg.com/post/building-an-arduino-robot-part-iv-a-not-so-basic-robot-firmware#commentform". If you want to check it My motor shield is Arduino motor shield r3

Thanks for replaying :smiley:

Hi, have you programmed an arduino before, where are your pinmode assignments, that is which pins are inputs and outputs.
What arduino is it written for.
I think you have copied this from another program, you have not even included the library needed to run the motor functions.
What level of electronics, programming in particular arduino do you have?

Tom... :slight_smile:

Might be a good idea to get some experience by going through the examples that came with the your IDE installation.