I am having some trouble with a current project of mine, I have a Ardumoto hooked up to a gear box, Arduino and a simple push button circuit on a breadboard. The problem comes when I try and have the Ardumoto respond to a button push, it will respond no problem, however if i wait and do not press the button it triggers the motors anyways. I have checked the current along the resister in the push button circuit and the button, when it triggers nothing changes at either of those points. I have followed the wiring tutorial for the shield, it is currently running on a wall adapter that powers both the shield and the Arduino. The code I am using is as follows.
int pwm_a = 3; //PWM control for motor outputs 1 and 2 is on digital pin 3
int pwm_b = 11; //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12; //dir control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13; //dir control for motor outputs 3 and 4 is on digital pin 13
int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup()
{
pinMode(pwm_a, OUTPUT); //Set control pins to be outputs
pinMode(pwm_b, OUTPUT);
pinMode(dir_a, OUTPUT);
pinMode(dir_b, OUTPUT);
pinMode(inPin, INPUT); // declare pushbutton as input
//set both motors to run at (45/255) 17% duty cycle (slow)
analogWrite(pwm_a, 30);
analogWrite(pwm_b, 30);
}
void loop()
{
//Left
val = digitalRead(inPin); //Read input value
if (val == LOW) //Check if the input is LOW (button has been pushed)
{
digitalWrite(dir_a, LOW);
digitalWrite(dir_b, HIGH);
}
}
I am using this https://www.sparkfun.com/products/666 Arduino, and this motor board SparkFun Ardumoto Shield Kit - KIT-14180 - SparkFun Electronics
I am worried that the board it's self might be damaged. Any help would be most welcome.
Thank you for your time.