i tried this code however it didn’t work to spin the fan at full speed
/*
Three useful functions are defined:
setupArdumoto() -- Setup the Ardumoto Shield pins
driveArdumoto([motor], [direction], [speed]) -- Drive [motor]
(0 for A, 1 for B) in [direction] (0 or 1) at a [speed]
between 0 and 255. It will spin until told to stop.
stopArdumoto([motor]) -- Stop driving [motor] (0 or 1).
setupArdumoto() is called in the setup().
The loop() demonstrates use of the motor driving functions.
*/
// Clockwise and counter-clockwise definitions.
// Depending on how you wired your motors, you may need to swap.
#define FORWARD 0
#define REVERSE 1
// Motor definitions to make life easier:
#define MOTOR_A 0
#define MOTOR_B 1
// Pin Assignments //
//Default pins:
#define DIRA 12 // Direction control for motor A
#define PWMA 3 // PWM control (speed) for motor A
#define DIRB 13 // Direction control for motor B
#define PWMB 11 // PWM control (speed) for motor B
////Alternate pins:
//#define DIRA 8 // Direction control for motor A
//#define PWMA 9 // PWM control (speed) for motor A
//#define DIRB 7 // Direction control for motor B
//#define PWMB 10 // PWM control (speed) for motor B
void setup()
{
setupArdumoto(); // Set all pins as outputs
driveArdumoto(MOTOR_A, FORWARD, 100); //testing sequence to verify fan is working
delay (1000);
driveArdumoto(MOTOR_A, FORWARD, 175);
delay (1000);
driveArdumoto(MOTOR_A, FORWARD, 200);
delay (1000);
driveArdumoto(MOTOR_A, FORWARD, 255);
delay (1000);
driveArdumoto(MOTOR_B, FORWARD, 100); //testing sequence to verify fan is working
delay (1000);
driveArdumoto(MOTOR_B, FORWARD, 175);
delay (1000);
driveArdumoto(MOTOR_B, FORWARD, 200);
delay (1000);
driveArdumoto(MOTOR_B, FORWARD, 255);
delay (1000);
}
void loop()
{
driveArdumoto(MOTOR_A, FORWARD, 255); // Motor A at max speed.
analogWrite(3, 255); //make sure fan is spinning full speed
driveArdumoto(MOTOR_B, FORWARD, 255); // Motor B at max speed.
analogWrite(11, 255); //make sure fan is spinning full speed
}
// driveArdumoto drives 'motor' in 'dir' direction at 'spd' speed
void driveArdumoto(byte motor, byte dir, byte spd)
{
if (motor == MOTOR_A)
{
digitalWrite(DIRA, dir);
analogWrite(PWMA, spd);
}
else if (motor == MOTOR_B)
{
digitalWrite(DIRB, dir);
analogWrite(PWMB, spd);
}
}
// stopArdumoto makes a motor stop
void stopArdumoto(byte motor)
{
driveArdumoto(motor, 0, 0);
}
// setupArdumoto initialize all pins
void setupArdumoto()
{
// All pins should be setup as outputs:
pinMode(PWMA, OUTPUT);
pinMode(PWMB, OUTPUT);
pinMode(DIRA, OUTPUT);
pinMode(DIRB, OUTPUT);
// Initialize all pins as low:
digitalWrite(PWMA, LOW);
digitalWrite(PWMB, LOW);
digitalWrite(DIRA, LOW);
digitalWrite(DIRB, LOW);
}