I'm pretty new to all this, and while I'm fairly alright at using c, I don't really know all the syntax and logic available in the arduino language. so essentially I have an uno with a motor shield on top, this is running two 7.2 volt motors, the board though doesn't seem to like me terribly much and seems to just run motor A pretty much forever, though sometimes it decides to stop. the current code that I uploaded is this
int dirA = 12;
int dirB = 13;
int speedA = 10;
int speedB = 11;
void setup()
{
pinMode (dirA, OUTPUT);
pinMode (dirB, OUTPUT);
pinMode (speedA, OUTPUT);
pinMode (speedB, OUTPUT);
}
void loop()
{
// move the motor A to one direction
digitalWrite (dirA, LOW);
digitalWrite(speedA, HIGH);
delay (100);
// stop the motor
digitalWrite(speedA, LOW);
delay(10000);
// move the motor B to one direction
digitalWrite (dirB, LOW);
digitalWrite(speedB, HIGH);
delay (1000);
}
currently the whole thing turns motor B on for a little bit then turns motor A on which just runs constlantly after a while motor b turns on and also runs constantly, so I'm really not sure what is going on here, even using very different code the results are often quite similar
I'm only guessing here without a circuit diagram, or photograph, or some such visual aid, but it sounds like you have your A and B wires mixed up a bit.
delay (100);
Assuming everything else is working correctly, you only have motor A on for 1/10 of a second, which is probably not enough time to spin the motor up to speed.
Also, you never stop motor B, so it will just run forever.
so in theory it should not have motor A running at all, motor B should run for half a second then go off for half a second, instead, motor A runs continuously and motor B runs for the half second then turns of for a second then on again like it should. Also some pictures of the set up, though all the wiring seems right to me.
So the red and black lines are just so that it's a bit easier to follow the wires and the green lines show which motor is A and which is B, and a link to the flickr account if you want a bigger image, (comes with a bonus really bad engineering drawing of an eye bolt) Gus Severin | Flickr
Also is there anything I can put in place of loop so that it doesn't loop?