HELP !! I NEED HELP !!!

void setup() { // initialize the digital pins as outputs. // Pin 13 has a LED connected on most Arduino boards: pinMode(13, OUTPUT); pinMode(7, OUTPUT);//Motor connected on pin 7 en 8, these are PWM capable pinMode(8, OUTPUT); } void loop() { digitalWrite(7, HIGH); //start motor at full speed digitalWrite(8, LOW); digitalWrite(13, HIGH); //turn on LED delay(5000);//wait digitalWrite(7, LOW); //stop motor digitalWrite(8, LOW); delay(1000); //wait a second to be sure motor is stopped digitalWrite(7, LOW); //start motor in reverse direction, full speed digitalWrite(8, HIGH); digitalWrite(13, LOW); //turn off led delay(5000);//wacht digitalWrite(7, LOW); //stop motor digitalWrite(8, LOW); delay(1000); //wait a second to be sure motor is stopped }

Info: I'm given a task by my professor. My job is to modify this code to make both motors to funtion at the same period of time such as : Going forward, Going backward/Reverse. Can somebody help me ? Below is the link for circuit diagram ( Link: http://people.mech.kuleuven.be/~dvanthienen/soiree_pratique/HackerManual.pdf)

So what's the problem ? It is a simple assignment. Does this mean you don't know how an H-bridge works or that you haven't read the datasheet ? What exactly is the reason you need help ?

And you should select your code before you hit the # key.

You have this:


.... but you really

want this.

So, you guys in the same class?- L293d Dual Motor Control - Programming Questions - Arduino Forum

iiPewDiePie:
Info: I'm given a task by my professor. My job is to modify this code to make both motors to funtion at the same period of time such as : Going forward, Going backward/Reverse. Can somebody help me ? Below is the link for circuit diagram ( Link: http://people.mech.kuleuven.be/~dvanthienen/soiree_pratique/HackerManual.pdf)

Apply your mind; have a look at the photo in that pdf.... One motor has pink wires from Arduino, one has blue. So trace back to the pin numbers on Arduino, and adjust / add code as appropriate. Hint: kind of double-up the code but on a new set of pins.

The title of your post does not inspire confidence.

Someone who can figure out your assignment could probably also figure that every post here is looking for help and would have used the title to convey some useful information.

...R

And we are definitely not here to help people cheat their assignments - ask
a reasonable question(s), don't just say "do my homework" - especially not
BY SHOUTING IT... Advice, hints, explanations are reasonable help, but
just doing it for you isn't fair on anyone.

JimboZA:

iiPewDiePie:
Info: I'm given a task by my professor. My job is to modify this code to make both motors to funtion at the same period of time such as : Going forward, Going backward/Reverse. Can somebody help me ? Below is the link for circuit diagram ( Link: http://people.mech.kuleuven.be/~dvanthienen/soiree_pratique/HackerManual.pdf)

Apply your mind; have a look at the photo in that pdf.... One motor has pink wires from Arduino, one has blue. So trace back to the pin numbers on Arduino, and adjust / add code as appropriate. Hint: kind of double-up the code but on a new set of pins.

Here's my code:

void setup() {
// initialize the digital pins as outputs.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(5, OUTPUT);//Motor aangesloten op pin 7 en 8, deze zijn PWM capable
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
digitalWrite(13, LOW);

}
void loop() {
analogWrite(5, 128);
digitalWrite(13, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(5, 255);
digitalWrite(13, HIGH);//Show speed on LED
delay(4000);
analogWrite(6, 128);
digitalWrite(12, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(6, 255);
digitalWrite(12, HIGH);//Show speed on LED
delay(4000);
}

Can you check for me ?

iiPewDiePie:
Can you check for me ?

No.

Use the #Code tags around your code, and please fix the title. You will never get any help SHOUTING "HELP HELP HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

// Per.

More or less correct, but you have it spinning in a circle I think, since the two motors are never at the same speed.

Perhaps change all the writes to analog , and make sure both motors are at same speed and correct direction for straight line.

But in any case, since this is a school assignment I've probably said too much already.....

did not find any reason& problem, say WHAT IS?THE MATTER , it is the very basic in any communication.

iiPewDiePie:

void setup() {

// initialize the digital pins as outputs.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(5, OUTPUT);//Motor aangesloten op pin 7 en 8, deze zijn PWM capable
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
digitalWrite(13, LOW);

}
void loop() {
analogWrite(5, 128);
digitalWrite(13, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(5, 255);
digitalWrite(13, HIGH);//Show speed on LED
delay(4000);
analogWrite(6, 128);
digitalWrite(12, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(6, 255);
digitalWrite(12, HIGH);//Show speed on LED
delay(4000);
}

Hi.
You did some changes in your sketch, but do you know what you changed ?
And if so what is the reason for this change ?
You also translated a comment to our language, but after that (i'm assuming that) you changed the line.
Be meticulous with your changes and the comments.
If you don't then these comments are worthless and would better be left out.

pinMode(5, OUTPUT);//Motor aangesloten op pin 7 en 8, deze zijn PWM capable
pinMode(6, OUTPUT);

Where have pins 7 and 8 gone ?
Besides, what has PWM capability to do with this sketch ?
You aren't using it.
In the original sketch pin 13 is used because it has an on board LED connected to it.
So you added pin 12 ,but for what reason ?
Would you like a LED to light up on that one too ?
In that case you have to make that happen.

Don't have us guessing here, by posting some sketch and ask us if this does what you are expecting it to do (without telling about your expectations).
In case the English language is a challenge to you, there is a Dutch section available too.

You have posted code that is meaningless without comments identifying how those arduino pins are connected to the L293.
Put some definitions in your code or at least comments identifying the signal or pin names of the L293 pins they connect to.

The only explanation I see is this line in what looks to be German.

 Motor aangesloten op pin 7 en 8, deze zijn PWM capable

Please put comments in that show what pins on the L293 the arduino pins go to. If you don't speak or write English then use the following format:
Arduino L293
// D5 ==================> 1A
// D6 ==================> 2A
// D7 ==================> 3A
// D8 ==================> 4A
// D9 ================> 1,2 EN
// D10 ================ 3,4 EN

void setup() {
// initialize the digital pins as outputs.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(5, OUTPUT);//Motor aangesloten op pin 7 en 8, deze zijn PWM capable
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
digitalWrite(13, LOW);

}
void loop() {
analogWrite(5, 128);
digitalWrite(13, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(5, 255);
digitalWrite(13, HIGH);//Show speed on LED
delay(4000);
analogWrite(6, 128);
digitalWrite(12, LOW);//Show speed on LED
delay(4000); //wait a bit
analogWrite(6, 255);
digitalWrite(12, HIGH);//Show speed on LED
delay(4000);
}

\

What's wrong with this picture ?
Have you read the L293 datasheet yet ?
Can you tell me what good it does to write PWM to both motors when you haven't done anything with the four input pins for direction of the motor (IN1,IN2,IN3,IN4) which to you (since you have no idea what those are would be 1A , 2,A,3A, 4A,
(PINS 2,7, 11, & 15)
L293 PINS
1A-pin-2
2A -pin-7
3A - pin 11
4A - pin 15.

There is nothing in your code for any of these pins. Writing PWM to the ENAble pins without setting the DIRection pins is pointless.
According to your comments, arduino pins 12 & 13 are driving leds and 5 & 6 are PWM pins driving the L293 ENable pins.
Your DIRection pins are even defined.

raschemmel:
looks to be German.

Dutch, actually.

JimboZA:
More or less correct, but you have it spinning in a circle I think, since the two motors are never at the same speed.

Perhaps change all the writes to analog , and make sure both motors are at same speed and correct direction for straight line.

But in any case, since this is a school assignment I've probably said too much already.....

Is my connection/code wrong ? Because both motors doesn't move at all.

Post a schematic of your actual connection... not the photo from the pdf, but of your actual setup. Hand drawn and cell phone pic should be good.

You have a mix of analog writes and digital writes: that's not inherently wrong but it's messy. For testing, perhaps make them all digital writes, which of course is just high and low. Make sure you have a high/low pair on each motors' inputs.... low/low or high/high gives no motion. High/low is one direction, low/high the other. If that works then change to analog writes and play with the speed. (One input low, the other pwm'd at various values. You may well find that the motor won't start with pwm values (ie analog writes) too low).

Here's a thought though: did you actually test the code you were given, just as it was, with only one motor? Might be worth testing that,. Do you know your 293 board is good?

Did you heed the warning in the pdf about voltage drops?- either through your board's regulator if you jumpered the board to use that, or through the L293 itself. You might not be providing enough voltage from your power source: that is, your supply voltage less the regulator drop (if used) less the 293 drop (always) might not leave enough to turn the motors.

(Just btw: Did you understand the part in the pdf where it says your board permanently enables both motors by wiring the 293's enable pins to 5v? In practice, you can take those to Arduino i/o pins and enable/disable the motors that way. But yours are hard-wired.)

What's wrong with this picture ?
Have you read the L293 datasheet yet ?
Can you tell me what good it does to write PWM to both motors when you haven't done anything with the four input pins for direction of the motor (IN1,IN2,IN3,IN4) which to you (since you have no idea what those are would be 1A , 2,A,3A, 4A,
(PINS 2,7, 11, & 15)
L293 PINS
1A-pin-2
2A -pin-7
3A - pin 11
4A - pin 15.

There is nothing in your code for any of these pins. Writing PWM to the ENAble pins without setting the DIRection pins is pointless.
According to your comments, arduino pins 12 & 13 are driving leds and 5 & 6 are PWM pins driving the L293 ENable pins.
Your DIRection pins are even defined.

You still haven't explained what your program is supposed to do

raschemmel:
Writing PWM to the ENAble pins without setting the DIRection pins is pointless.

According to the linked PDF, though, the enable pins are hard-wired high. Direction AND speed are therefore controlled through the inputs.

MarkT:
And we are definitely not here to help people cheat their assignments - ask
a reasonable question(s), don't just say "do my homework" - especially not
BY SHOUTING IT... Advice, hints, explanations are reasonable help, but
just doing it for you isn't fair on anyone.

void setup() { 
 // initialize the digital pins as outputs. 
 // Pin 13 has a LED connected on most Arduino boards: 
 pinMode(13, OUTPUT);
 
 pinMode(7, OUTPUT);//Motor connected on pin 7 en 8, these are PWM capable 
 pinMode(8, OUTPUT);
 
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 
} 
 
void loop() { 
 digitalWrite(7, HIGH); //start motor at full speed 
 digitalWrite(8, LOW); 
 digitalWrite(13, HIGH); //turn on LED 
 delay(5000);//wait 
 
 digitalWrite(7, LOW); //stop motor 
 digitalWrite(8, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(7, LOW); //start motor in reverse direction, full speed 
 digitalWrite(8, HIGH); 
 digitalWrite(13, LOW); //turn off led 
 delay(5000);//wacht 
 
 digitalWrite(7, LOW); //stop motor 
 digitalWrite(8, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(5, HIGH); //start motor at full speed 
 digitalWrite(6, LOW); 
 digitalWrite(13, HIGH); //turn on LED 
 delay(5000);//wait 
 
 digitalWrite(5, LOW); //stop motor 
 digitalWrite(6, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(5, LOW); //start motor in reverse direction, full speed 
 digitalWrite(6, HIGH); 
 digitalWrite(13, LOW); //turn off led 
 delay(5000);//wacht 
 
 digitalWrite(5, LOW); //stop motor 
 digitalWrite(6, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
}

JimboZA:

iiPewDiePie:
Info: I'm given a task by my professor. My job is to modify this code to make both motors to funtion at the same period of time such as : Going forward, Going backward/Reverse. Can somebody help me ? Below is the link for circuit diagram ( Link: http://people.mech.kuleuven.be/~dvanthienen/soiree_pratique/HackerManual.pdf)

Apply your mind; have a look at the photo in that pdf.... One motor has pink wires from Arduino, one has blue. So trace back to the pin numbers on Arduino, and adjust / add code as appropriate. Hint: kind of double-up the code but on a new set of pins.

void setup() { 
 // initialize the digital pins as outputs. 
 // Pin 13 has a LED connected on most Arduino boards: 
 pinMode(13, OUTPUT);
 
 pinMode(7, OUTPUT);//Motor connected on pin 7 en 8, these are PWM capable 
 pinMode(8, OUTPUT);
 
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 
} 
 
void loop() { 
 digitalWrite(7, HIGH); //start motor at full speed 
 digitalWrite(8, LOW); 
 digitalWrite(13, HIGH); //turn on LED 
 delay(5000);//wait 
 
 digitalWrite(7, LOW); //stop motor 
 digitalWrite(8, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(7, LOW); //start motor in reverse direction, full speed 
 digitalWrite(8, HIGH); 
 digitalWrite(13, LOW); //turn off led 
 delay(5000);//wacht 
 
 digitalWrite(7, LOW); //stop motor 
 digitalWrite(8, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(5, HIGH); //start motor at full speed 
 digitalWrite(6, LOW); 
 digitalWrite(13, HIGH); //turn on LED 
 delay(5000);//wait 
 
 digitalWrite(5, LOW); //stop motor 
 digitalWrite(6, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
 
 digitalWrite(5, LOW); //start motor in reverse direction, full speed 
 digitalWrite(6, HIGH); 
 digitalWrite(13, LOW); //turn off led 
 delay(5000);//wacht 
 
 digitalWrite(5, LOW); //stop motor 
 digitalWrite(6, LOW); 
 delay(1000); //wait a second to be sure motor is stopped 
}