My code does a really basic motor spin clockwise for 3 seconds and then rests for 3 seconds before repeating.
My code was working, and then today(without changing anything) it stopped working. In order to get it working again I had to include a line that sets the H-bridge 'reset' pin to HIGH. (After some research I found the default value should be HIGH)
Why am I now required to set the value to HIGH? Is it ok to keep doing this? And is the fact that the H-bridge is not setting the reset properly a sign of a problem?
Any help is greatly appreciated! Let me know if any other information is needed.
Setup:
Arduino Uno
Pololu md07a H-bridge (Pololu High-Power Motor Driver 18v15)
DC motor
Code:
// Basic motor spin
// Assign Pins
int dir = 1;
int pwm = 2;
int reset = 3;
//Variables
int speedOfRotate=255;
void setup() {
// put your setup code here, to run once:
pinMode(dir, OUTPUT);
pinMode(pwm, OUTPUT);
pinMode(reset, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
/////////////////////////////////////////////////////////////////////////
//Code only works with the following line:
digitalWrite(reset, HIGH); // reset h-bridge
//////////////////////////////////////////////////////////////////////
//Turn clockwise
analogWrite(dir, 0);
analogWrite(pwm, speedOfRotate);
delay(3000); //waits for 3 seconds
// Do nothing
analogWrite(dir, 0);
analogWrite(pwm, 0);
delay(3000); //waits for 3 seconds
} //End loop