problems with program on ARDUINO by using MOTOR DC and L298

HY
I m sorry for my English
I need really ur help
in my project i need to command a MOTOR DC ( 12 V ) by a button to turn right and another button to turn left and all this will be commanded by an ARDUINO UNO and L289 but when i did the schema in ISIS PROTEUS 7.8 the MOTOR didn't turn.

int ENA=5; //Connecté à Arduino pin 5(sortie pwm)
int IN1=2; //Connecté à Arduino pin 2
int IN2=3; //Connecté à Arduino pin 3
const int boutonP = 8;
const int boutonN = 9;
int etatBoutonP;
int etatBoutonN;

void setup() {
 pinMode(ENA,OUTPUT);//Configurer les broches comme sortie
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(boutonP, INPUT); //le boutonP est une entrée
 pinMode(boutonN, INPUT); //le boutonN est une entrée
 
digitalWrite(ENA,LOW);// Moteur A - Ne pas tourner (désactivation moteur)


}

void loop() {
  etatBoutonP = digitalRead(boutonP);
  etatBoutonN = digitalRead(boutonN);
  
     if(etatBoutonP == LOW ) //test si le bouton a un niveau logique HAUT
   {
      digitalWrite(ENA,HIGH);// Moteur A - Ne pas tourner (désactivation moteur)

      // Direction Positive
     digitalWrite(IN1,LOW); 
     digitalWrite(IN2,HIGH);

   }
   else{
         digitalWrite(ENA,LOW);// Moteur A - Ne pas tourner (désactivation moteur)
     }

     if(etatBoutonN == LOW ) //test si le bouton a un niveau logique HAUT
   {
      digitalWrite(ENA,HIGH);// Moteur A - Ne pas tourner (désactivation moteur)

      // Direction du Moteur Negative
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
   }
   
   else{
         digitalWrite(ENA,LOW);// Moteur A - Ne pas tourner (désactivation moteur)
}
   
 
}

THANKS

i do not have an answer for you but from eperience, be sure to use diodes! you will pop your board going back and forth if not protected.

What about the VS pin? He's feeling so alone there...
You need shunt diodes (shottky ones are even better).

If you post a screenshot of page 2 of the datasheet I'll tell you what's wrong with your circuit.

Never disconnect the motor wire with power applied.
Add LEDs to display the DIR (INput s) and PWM (ENable).
Get some jumper wires and remove the wires connected to the arduino.
Install Jumpers from GND to the two INput pins (5 & 7).
Connect a jumper from +5V to Enable pin 6.
Move the jumper from IN2 (pin-7) from GND to +5V.
The motor should turn.

This is a known good example sketch. You just need to change the pin numbers to match you circuit.

 int switchPin = 2; // switch input
int motor1Pin1 = 3; // pin 2 on L293D
int motor1Pin2 = 4; // pin 7 on L293D
int enablePin = 9; // pin 1 on L293D

void setup() {
    // set the switch as an input:
    pinMode(switchPin, INPUT);

    // set all the other pins you're using as outputs:
    pinMode(motor1Pin1, OUTPUT);
    pinMode(motor1Pin2, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH);
}

void loop() {
    // if the switch is high, motor will turn on one direction:
    if (digitalRead(switchPin) == HIGH) {
        digitalWrite(motor1Pin1, LOW); // set pin 2 on L293D low
        digitalWrite(motor1Pin2, HIGH); // set pin 7 on L293D high
    }
    // if the switch is low, motor will turn in the opposite direction:
    else {
        digitalWrite(motor1Pin1, HIGH); // set pin 2 on L293D high
        digitalWrite(motor1Pin2, LOW); // set pin 7 on L293D low
    }
}

Here's another one: Just comment out the code for the second motor.

 /**
 * Bruno Santos, 2013
 * feiticeir0@whatgeek.com.pt
 * Small code to test DC motors - 2x with a L298 Dual H-Bridge Motor Driver
 * Free to share
 **/
 //Testing the DC Motors
//Define Pins
 //Motor A
 int enableA = 10;
 int pinA1 = 2;
 int pinA2 = 3;
//Motor B
 int enableB = 9;
 int pinB1 = 4;
 int pinB2 = 5;
void setup() {
Serial.begin (9600);
 //configure pin modes
 pinMode (enableA, OUTPUT);
 pinMode (pinA1, OUTPUT);
 pinMode (pinA2, OUTPUT);
pinMode (enableB, OUTPUT);
 pinMode (pinB1, OUTPUT);
 pinMode (pinB2, OUTPUT);
}
void loop() {
 //enabling motor A
 Serial.println ("Enabling Motor A");
 digitalWrite (enableA, HIGH);
//do something
 //forward
 Serial.println ("Forward");
 digitalWrite (pinA1, HIGH);
 digitalWrite (pinA2, LOW);
//5s forward
 delay (5000);
//reverse
 digitalWrite (pinA1,LOW);
 digitalWrite (pinA2,HIGH);
//5s backwards
 delay (5000);
//stop
 digitalWrite (enableA, LOW);
 delay (5000);
//enabling motor B
 //Since motor B is mounted reversed, PINs must be exchanged
 Serial.println ("Enabling Motor A");
 digitalWrite (enableB, HIGH);
//do something
 //forward
 Serial.println ("Forward");
 digitalWrite (pinB1, LOW);
 digitalWrite (pinB2, HIGH);
//5s forward
 delay (5000);
//reverse
 digitalWrite (pinB1,HIGH);
 digitalWrite (pinB2,LOW);
//5s backwards
 delay (5000);
//stop
 digitalWrite (enableB, LOW);
 delay (5000);
 }

If you post a screenshot of page 2 of the datasheet I'll tell you what's wrong with your circuit.

You should not be posting for this problem. (based on the documentation you have provided)

thanks for the answers
i think i don't have a problem in the program but in how i connect the l298 with the MOTOR and arduino .
ashemmel i didn't really understand what u say about the jumper and what datasheet do u need.
and thanks

I don't need it. You need it. It's obvious why the motor isn't turning if the schematic you posted is correct.
Can you guess why ?

i have a problem in schema but datasheet didn't help me

What problem in the schematic are you referring to ?

i think i conncted the arduino and L298 in a wong way

I am asking you (again and again) , do you or do you not know what is wrong with the schematic ?
It is a yes or no question. If you answer no , I will tell you. I am not going to tell you until you answer the above question, but I will tell you that anyone looking at your schematic would spot it immediately. I have already given you a clue. You ignored it. .

raschemmel:
I am asking you (again and again) , do you or do you not know what is wrong with the schematic ?
It is a yes or no question. If you answer no , I will tell you. I am not going to tell you until you answer the above question, but I will tell you that anyone looking at your schematic would spot it immediately. I have already given you a clue. You ignored it. .

And could be even what I said earlier too... But mine was an explicit (and a bit poetic) answer, hope it is not ignored.

You need shunt diodes (shottky ones are even better).

You don't need the diodes because there is no motor power supply ....(look at the schematic).

thexeno:
What about the VS pin? He's feeling so alone there...
You need shunt diodes (shottky ones are even better).

raschemmel:

You need shunt diodes (shottky ones are even better).

You don't need the diodes because there is no motor power supply ....(look at the schematic).

VS is the motor power supply... :wink:
I was keeping myself from repeating that, to enforce amoultii to read better, as you want too
And diodes are needed, are not included in the IC, when motor will work

I know the diodes are necessary if you actually HAVE a power supply but as you pointed out I was refraining from just blurting out the answer but I couldn't hold it any longer. It was meant to be a fecetious remark implying that diodes are unnecessary as long as power is not connected. You know what I mean. I think the OP died.

raschemmel:
I know the diodes are necessary if you actually HAVE a power supply but as you pointed out I was refraining from just blurting out the answer but I couldn't hold it any longer. It was meant to be a fecetious remark implying that diodes are unnecessary as long as power is not connected. You know what I mean. I think the OP died.

Yes I get it. I thought that asking about the VS pin was sufficient... and instead. We'll see if that was the problem