// set enablePin high so that motor can turn on: ADDED
digitalWrite(enablePin, HIGH);
}
void loop()
{
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
}
if this is all correct it must be something with the connections i have. can someone verify this code should work so that i can move on from editing code to trying to fix my circuit.
also im using this schematic with the capacitor. http://itp.nyu.edu/physcomp/Labs/DCMotorControl im not using the switch though. is this schematic still good if i did everything but the switch?
// set enablePin high so that motor can turn on: ADDED
digitalWrite(enablePin, HIGH);
}
void loop()
{
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
}
well thats not going to work if you dont have a delay because the pin is switched too fast to make any sense to the motor
ok guys. so since with the help of newbie and a bunch of you ive finally figured out simple code that should make my motor spin the wheels. i need to figure out why it is not. so now i am on to my wiring. im using this schematic
what is crossed out in green i didnt use and i labeled and put in what i added. also im not using a 9v im using a 4 battery pack of AA batteries.
if anyone sees anything that i messed up or a better way to go about please post or message me. thanks a lot.
still not running. im at a lost considering my code and my wiring should both work. with other code i was trying i also made the led blink to see if the code was working at all and it was. i have no idea what to do as of right now. ive changed my wiring and coding twice with no success.
EDIT: im also going to get rid of the extra ground wire along with the two black wires to the left of it in the schematic because that side doesnt need ground because im not using it.
SECOND EDIT: im going to try a few things that will most likely not work (hard to be positive right now)
changed to a 9v
also im going to try to add simple LED code to see if thats getting sent to the board and being processed.
hah sorry when i first made my account i just kind of came on looked quickly and made on. if a mod wants to move it that would be great. i just now wrote up this code which the led is blinking but no motor movement.
#define m1p1 3 //motor one pin one #define m1p2 4 //motor one pin two
const int ledPin = 13;
void setup()
{
pinMode (m1p1,OUTPUT);
pinMode (m1p2,OUTPUT);
pinMode(ledPin, OUTPUT);
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}
Hmmm well but i see you use a enable pin in your schematic i guess pin 9 You need to put it high at all time to run the motors ! ( i didnt read the entire code )
i was planning on trying to bring in an enable pin the other day but i thought that had something to do with the switch and knowing when it was on. are you looking at the schematic that i edited with the green Xs? because it shows the switch crossed out. otherwise i dont see anything around pin 9 i will but an enablePin(HIGH) im my program a little later this morning and see how things go.
ok so once again i went a completely different way and FINALLY success. i used the full schematic and didnt eliminate the switch and altered some code up and everything is working as of now.