I am using the motor shield with my Uno to drive a Nikko car. The steering has been sorted out but the motor doesn't change speed. I am using the Nikko 7.2 v battery. The motor draws 1.2 amps. The serial monitor displays the increasing count but the speed or voltage across ChanA (on the motor shield) doesn't vary.
Is the Motor shield damaged?
Thanks in advance
// FirstNikkoDemo
// By EP Jasper, 6/2/12
// Uses Arduino Motor Shield, R3
// Drive motor; Blue lead to ChanA+, Red lead to ChanA-
// Steering Servo; Black lead to Gnd., Red lead to 5v.,
// Yellow lead to pin D7
#include <Servo.h>
Servo myservo;
int pos = 0; // variable to store the servo position
int dirA = 12; // pin 12
int speedA = 3; // pin 3
void setup()
{
pinMode (dirA, OUTPUT);
pinMode (speedA, OUTPUT);
digitalWrite (dirA, LOW); // LOW = Reverse
Serial.begin(9600); // initialize serial
myservo.attach(7); // Pin D7
}
void loop()
{
/* for (pos = 30; pos <110; pos += 2)
{
myservo.write(pos); // send position to servo
delay(500); // hold 1.5 seconds
Serial.println(pos); // send it to serial monitor
delay(100);
}
*/
// move the motor A to one direction increasing speed
digitalWrite (dirA, LOW); // Forward
for (int j = 0; j < 133; j += 1)
{
digitalWrite (speedA, j);
delay (2000);
Serial.println(j);
delay(2000);
}
// stop the motor
digitalWrite(speedA, LOW);
delay(100); // keep the motor rolling for one second
}