help me plzzz

i m using arduino for my project and i used a l293D to turn it in both ways but i want to turn the motor for 2 second
what is the code for that

#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
int led = 4;
int ledPin1=12;
int motor1Pin1 = 3; // pin 2 (Input 1) du L293D
int motor1Pin2 = 4; // pin 7 (Input 2) du L293D
int enablePin = 9; // pin 1 (Enable 1) du L293D
Servo microservo;
int pos = 0;
byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip = { 192, 168, 1, 178 }; // ip in lan (that’s what you need to use in your browser. (“192.168.1.178”)
byte gateway = { 192, 168, 1, 1 }; // internet access via router
byte subnet = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
pinMode(led, OUTPUT);
microservo.attach(7);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}

void loop() {
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}

//if HTTP request has ended
if (c == ‘\n’) {
Serial.println(readString); //print to serial monitor for debuging

client.println(“HTTP/1.1 200 OK”); //send new page
client.println(“Content-Type: text/html”);
client.println();
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
client.println(“commande a distance d’un portail”);
client.println("");
client.println("");
client.println(“

Commande a distance d’un eclairage et d’un portail electrique

”);
client.println("
");
client.println("
“);
client.println(“

Arduino with Ethernet Shield

”);
client.println(”
“);
client.println(”

kais boussadia

“);
client.println(”");

client.println(“

projet fin d’etude -isitcom

“);
client.println(”
“);
client.println(”
“);
client.println(”<a href=”/?button1on"">allumer eclairage");
client.println("
“);
client.println(”
“);
client.println(”
“);
client.println(”<a href="/?button1off"">eteindre eclairage
“);
client.println(”
“);
client.println(”
“);
client.println(”<a href="/?button2on""> ouvrir portail “);
client.println(”
“);
client.println(”
“);
client.println(”
");

client.println("<a href="/?button2off""> fermer portail
");

client.println("
“);
client.println(”");
client.println("");

delay(1);
//stopping client
client.stop();
//controls the Arduino if you press the buttons
if (readString.indexOf("?button1on") >0){
digitalWrite(led, HIGH);
digitalWrite(ledPin1,HIGH);
}
if (readString.indexOf("?button1off") >0){
digitalWrite(led, LOW);
digitalWrite(ledPin1,LOW);
}
if (readString.indexOf("?button2on") >0){
for(pos = 0; pos < 360; pos += 4) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
microservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
if (readString.indexOf("?button2off") >0){
for(pos = 360; pos>=1; pos-=4) // goes from 180 degrees to 0 degrees
{
microservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
//clearing string for next read
readString="";

}
}
}
}
}

i need to change this code for my DC motor instead of servomoteur

Hi,

Re: help me plzz

Does not tell us what you are needing help for, please edit the subject to something like;

Help, servo control by Ethernet.

That way you will probably get someone who can help you, all the forum members do not read all the posted requests, you have to let them know in the subject of your request what you need.
If you look at the subject of other posts, there is a lot of space for you to write your request.

Tom… :slight_smile:

Your first step is to get the motor to do what you want, so create a new sketch for just motor control and work on that. After that you can look at the other parts of the problem.

Mark

i m just asking how can i make to motor turn for like 3 sec it's just a line of program
and thank you :slight_smile:

i m just asking how can i make to motor turn

That's one thing.

for like 3 sec

That's another.

Before you get into trying to control your motor over the internet, you should make sure you can control it with a dirt simple sketch. There are several examples provided with the IDE that control servo motors. Give one of them a spin.

Then, there is the blink without delay example that lets you start something happening, and stop it later. Read, understand, and EMBRACE that example to turn your motor off 3 seconds after it was turned on.