Aurdino coding to control a motor

Am using l293dne ic with arduino to control a motor.Could you please go through my code and help me out

//Motor A
const int motorpin1 = 6; // Pin 6 of L293
const int motorpin2 = 9; // Pin 3 of L293

void setup() {
pinMode(motorpin1, OUTPUT);
pinMode(motorpin2, OUTPUT);

digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
Serial.begin(9600);
}

void loop(){
if(Serial.available()>0)
{
char incomingByte = Serial.read();
Serial.println(incomingByte);
if(incomingByte=='a'){
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
delay(200);
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, HIGH);

Serial.println("one way");
}
else if(incomingByte=='s'){
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
delay(200);
digitalWrite(motorpin1, HIGH);
digitalWrite(motorpin2, LOW);

Serial.println("other way");
}
else{
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
}
}
}
If we input "a" in the serial monitor the motor should rotate in one direction and if we input "s" the motor should rotate in another direction but it is not happening the motor is idle but i get the output on serial monitor like this:

a
one way

s
other way
There is no problem with hardware connections.

Could you please help me with this.Thanks in advance

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

Hi,
Have you got some code that shows you have control of the motors in the first place, without serial monitor control?

Thanks... Tom... :slight_smile:

Please post a schematic/wiring diagram because either your wiring is wrong or the comments in the code are. The control pins on an L293 are not 3 and 6.

Have you tried a simple program that just moves the motor forward and back? That's how you know if the wiring and power connections are correct.

Steve