I am using an Arduino uno R3 with the motor shield R3 with 1 DC motor (http://www.maplin.co.uk/small-motor-3738) pluged in by the USB port (because I dont have a proper power cable). When i first used the DC motor it went way too fast so i turned the speed down but then it didn't start so I turned it back up to 255 the speed I started with. The motor still didn't start so I tested the motor with a 1.2 volts fully charged rechargeable battery and it worked fine as before but when I plug it into the Arduino it only makes a quite noise. The LEDs on the shield also seem to be dimmer than before.
This is the code I used
const int pwm_cha = 3;
const int dir_cha = 12;
const int brake_cha = 9;
const byte motor_speed = 270;
void setup()
{
pinMode(pwm_cha, OUTPUT);
pinMode(brake_cha, OUTPUT);
digitalWrite(pwm_cha, HIGH);
digitalWrite(brake_cha, LOW);
pinMode(dir_cha, OUTPUT);
digitalWrite(dir_cha, LOW);
}
void loop()
{
analogWrite(pwm_cha, motor_speed);
delay(2000);
analogWrite(pwm_cha, 0);
delay(2000);
}
Please give ideas on what I can do to solve this, thanks.
const byte motor_speed = 270;
is correct? 270 sounds a bit high, I'd expect max 255. \$\endgroup\$