OFF TOPIC replies deleted.
I would have just hidden them but could not find the "hide" button.
REMINDER TO STAY ON TOPIC PEOPLE !
OFF TOPIC replies deleted.
I would have just hidden them but could not find the "hide" button.
REMINDER TO STAY ON TOPIC PEOPLE !
Thanks so much! That really helped. One question: The article states you can 'connect one motor to OUT1 and OUT2 and the other motor to OUT3 and OUT4. You can interchange the connections of your motor. There is technically no right or wrong way.' So just so I am not missing something, does that mean it is okay to connect the red (+) and black (-) motor wires to OUT1 and OUT2 respectively or OUT 2 and OUT 1 respectively, i.e. polarity does not matter?
Hi!
Polarity matter for rotation direction but you won't burn the motor inverting the wires.
Invert polarity is exactly what a H bridge does.
Best regards.
Great thanks. This program complies and uploads properly but will not run. Below is the configuration of the parts. Does anyone know what I am doing wrong?
I am trying to do is power both the Arduino and the 12V DC motor with a single 12V power supply which is allowed if one uses the VIN and GND ports on the Arduino. I want to turn on the motor and do the following for 36,000,000ms (10 hours): spin the motor at its max speed for 833ms and then pause for 3,500ms (3.5 sec) for a total of 150 times. Then pause for 240,000ms (4 min) and start over another 150 times, i.e. for 10 hours total. I didn't use the #include function above since I can't figure out even after searching online if I am supposed to use it or what it does.
//L293D
// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
unsigned long startmillis;
int i;
void setup()
{
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
// Turn off motors - Initial state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
//initial start time
startmillis = millis();
}
//Run program for 7200000ms (2 hrs)
void loop() {
while (millis() - startmillis < 36000000ul) {
//Spin motor for 833ms & pause for 3500ms, do 150 times
//Motor Control - in1,in2
for (i = 0; i < 150; i++) {
//Spin motor clockwise
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(833ul); //run 833ms
//Pause motor for 3500ms
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(3500ul); //pause 3.5 secs
}
// Turn off motors
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(240000ul);
}
}
I have moved the topic out of the "Jobs and Paid Consultancy" forum category and back to the section of the forum for free assistance as requested.
Best wishes for success with your project @anon628042
pert
12 V on VIN will overheat the 5 V regulator.
Add a step down to drop the voltage to 7 V.
Ok but then I am wondering why I find so many references on here that it is ok to put 12V into the VIN if you also use the GND pin?
Does not matter now as I powered the Arduino with USB to provide the 5V. I removed the 12V going into the VIN as shown below. The program still uploads fine but won't run. I confirmed the 12V is providing power and that the motor does work when directly connected to the power 12V. I even switched the 2 motor wires around even though it isn't supposed to make a difference and the motor still does not turn. Ignore that I don't the USB plugged into power as I do just didn't know how to update the image. Updated configuration:
Ok thanks. I have eliminated the 12V into the Arduino VIN but am stumped why the program uploads properly but will not run. I tried different baud rates for the com port but am not sure which one I am supposed to use. Do you know or otherwise know what is wrong with my configuration? I even replaced the L293D with a new one.
Well, maybe you need to set the enable pin? I only see you setting two outputs low. Is the enable low or high when you declare it as an output but write nothing to it? Maybe try alternating it, with a delay in between each change, to see if the motor runs and stops?
The code is running but don't do what do you want.
Add debug messages to print information that can help you like I did here:
Thanks but you can't add a DC motor in that program. They only have stepper motors.
I tried that and I even uploaded the program in post 27 and that won't run either.
Your code is running on simulator, I have added debug messages only.
The led represents your motor.
Ah ok. It is turning the light on just under every 4500ms which is equal to the 3500ms + 833ms in my program so the proper signal is being sent. So the mystery then is why the motor does not turn.
Not that this is now the issue as I need to figure out why the motor does not turn but I'll see if it turns off in 150 * 4,333ms = 10.8min as it should then stops for 240,000ms as the program requires and then starts again with another 150 cycles.
you could change some of those numbers temporarily to make it easier to test, unless you LIKE watching paint dry. Just sayin'.
That was a great idea, thanks, but too late, lol. Using that simulator the program works exactly as it should in terms of doing the 150 cycles, pausing the required time and then doing the 150 cycles again. Given that proper messages are therefore obviously being sent to the L239D chip, the motor does work when hooked up directly to the 12V power supply, the power supply wires the connect to the chip show 12V and the wires from the Arduino to the chip show 5V it has to be something to do with the motor not getting the signal to turn on.
Are you playing with a sim, or real hardware. If the latter, please post your latest code.
Both. Here is the code. What is interesting is I can see the amperage on the power supply jump up over 300mA, which is what the motor needs to turn, and then dropping to zero and both for the time period in the program over and over but the motor just does not turn.
//L293D
// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
unsigned long startmillis;
int i;
void setup()
{
// Set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
// Turn off motors - Initial state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
// Set motor to maximum speed
analogWrite(enA, 255);
//initial start time
startmillis = millis();
}
//Run program for 7200000ms (2 hrs)
void loop() {
while (millis() - startmillis < 36000000ul) {
//Spin motor for 833ms & pause for 3500ms, do 150 times
//Motor Control - in1,in2
for (i = 0; i < 150; i++) {
//Spin motor clockwise
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(833ul); //run 833ms
//Pause motor for 3500ms
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(3500ul); //pause 3.5 secs
}
// Turn off motors
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(240000ul);
}
}
Quick test, jumper the other three GND pins of the L293D to the first one which you have connected.