johncc:
That's great-- your shield and wiring is working!void leftMotor( int direction, int speed)
{
digitalWrite( LEFT_MOTOR, direction); //Establishes direction fwd/back
digitalWrite( LEFT_BRAKE , LOW); //Disengage the Brake
digitalWrite( LEFT_SPINNER, speed); //Spins the motor
}
void rightMotor( int direction, int speed)
{
digitalWrite( RIGHT_MOTOR, direction); //Establishes direction fwd/back
digitalWrite( RIGHT_BRAKE , LOW); //Disengage the Brake
digitalWrite( RIGHT_SPINNER, speed); //Spins the motor
}
Can you see how you would add a rightMotor() ? Cheers, John
seem right for this section of code?
Here is a quick attempt at adding the Right pins and void setup, a little confused as to where to put stuff in the loop...
/*
Mowbot Test Sketch 1 -- Motor
*/
const int RIGHT_MOTOR=13, RIGHT_BRAKE=8, RIGHT_SPINNER=11;
const int LEFT_MOTOR=12, LEFT_BRAKE=9, LEFT_SPINNER=3;
const int FORWARD=HIGH, REVERSE=LOW;
const int FULLSPEED=255;
void leftMotor( int direction, int speed)
{
digitalWrite( LEFT_MOTOR, direction); //Establishes direction of Channel A
digitalWrite( LEFT_BRAKE , LOW); //Disengage the Brake
digitalWrite( LEFT_SPINNER, speed); //Spins the motor
}
void rightMotor( int direction, int speed)
{
digitalWrite( RIGHT_MOTOR, direction); //Establishes direction of Channel B
digitalWrite( RIGHT_BRAKE , LOW); //Disengage the Brake
digitalWrite( RIGHT_SPINNER, speed); //Spins the motor
}
void setup()
{
pinMode(LEFT_MOTOR, OUTPUT);
pinMode(LEFT_BRAKE, OUTPUT);
leftMotor( FORWARD, FULLSPEED);
pinMode(RIGHT_MOTOR, OUTPUT);
pinMode(RIGHT_BRAKE, OUTPUT);
rightMotor( FORWARD, FULLSPEED);
void loop()
{
leftMotor( FORWARD, FULLSPEED);
delay( 4000); // on and off every 4 seconds
leftMotor( FORWARD, 0 );
delay( 4000);
}