RayLivingston:
Your issue is in the code you did NOT post....
Regards,
Ray L.
Right... Like I said, I had to wait 5 minutes, since I'm under 100 posts.
The working example code can be found at this link. I'll also be posting it, once my next 5 minutes are up
Here's my code:
/*
Web Server
A simple web server
Circuit:
Ethernet shield attached to pins 10, 11, 12, 13
*/
//-------------------------------------------------------------------------------------------------------
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
byte mac[] = {0xA8, 0x61, 0x0A, 0xAE, 0x0E, 0x5D };
// The IP address will be dependent on your local network:
// assign an IP address for the controller:
IPAddress ip(192, 168, 1, 3);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
// Initialize the Ethernet server library with the port you want to use.
EthernetServer server(8082);
String readString;
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------
// Any extra codes for Declaration :
// Declare Pin 8 as an LED because thats what we will be connecting the LED to.You could use any other pin and would then have to change the pin number.
int led = 8;
int enablePin = 4;
int directionPin = 3;
int stepPin = 2;
int numberOfSteps = 400;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 10; // milliseconds - or try 1000 for slower steps
//-------------------------------------------------
//-------------------------------------------------------------------------------------------------------
void setup()
{
//-------------------------------------------------
// Extra Set up code:
pinMode(led, OUTPUT); //pin selected to control
pinMode(enablePin, OUTPUT);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
//-------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//enable serial data print
Serial.begin(9600);
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
Serial.println("Stepper Motor Controller Test 1.0");
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
void loop() {
//Serial.println("Made it to loop"); //Checking to see if program made it to loop
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
while (client.connected())
{
//Serial.println("Made it to while loop"); //Checking to see if program made it to while loop
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);
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
//if HTTP request has ended
if (c == '\n') {
Serial.println(readString); //print to serial monitor for debuging
//--------------------------------------------------------------------------------------------------------
// Needed to Display Site:
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
//--------------------------------------------------------------------------------------------------------
//-------------------------------------------------
// what is being Displayed :
client.println("<TITLE>Stepper Motor Control</TITLE>");
client.println("<center>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Individual Motor Control/H1>");
client.println("<hr />");
client.println("<center>");
client.println("<a href=\"/?clockwise\"\">Turn Motor Clockwise</a>");
client.println("
");
client.println("
");
client.println("<a href=\"/?counterclockwise\"\">Turn Motor Counter-Clockwise</a>
");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
//Testing server set up with light on//
digitalWrite(led, HIGH);
Serial.println("Server is set up");
//-------------------------------------------------
// Code which needs to be Implemented:
if (readString.indexOf("?clockwise") > 0) //checks for on
{
digitalWrite(enablePin, LOW); // enable motor
Serial.println("Motor Enabled");
digitalWrite(directionPin, HIGH);
for (int n = 0; n < numberOfSteps; n++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
}
digitalWrite(enablePin, HIGH);
Serial.println("Disabled");
}
else {
if (readString.indexOf("?counterclockwise") > 0) //checks for off
{
digitalWrite(enablePin, LOW); //enable motor
Serial.println("Motor Enabled");
digitalWrite(directionPin, LOW);
for (int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
}
digitalWrite(enablePin, HIGH);
Serial.println("Disabled");
}
}
//clearing string for next read
readString = "";
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
}
}
}
/*else {
Serial.println("Client not available"); //Didn't enter client loop
}
*/
}
[\code]
The working example code can be found at [url=https://www.instructables.com/id/Easy-Basic-Arduino-Ethernet-Controller/]this link.[/url] I'll also be posting it, once my next 5 minutes are up.