Hi guys,
I am new to arduino.
Can you somebody tell how how to make simple html program to control dc motor speed.
Objective of program is to make text box on html page. User will enter the number (Motor speed) and
how to convert that entered number into int variable to program it using c language.
I am stuck here i know how to control but dont know about how to read user entered value in textbox on html page.
Please see the void ProcessCheckbox(EthernetClient cl) function . In that how to take int value from user i.e. text box and assign it int variable t2.
#include <SPI.h>
#include <Ethernet.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 100); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80
String HTTP_req; // stores the HTTP request
boolean LED_status = 0; // state of LED, off by default
void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin(); // start to listen for clients
Serial.begin(9600); // for diagnostics
pinMode(12, OUTPUT); // declares pin 12 as output
}
void loop()
{
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
HTTP_req += c; // save the HTTP request 1 char at a time
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// send web page
client.println("");
client.println("");
client.println("");
client.println(" ");
client.println("");
client.println("");
client.println("
ECT MOTOR SPED CONTROL
");client.println("
ENTER THE SPEED.
");client.println("<form method="get">");
ProcessCheckbox(client);
client.println("");
client.println("");
client.println("");
Serial.print(HTTP_req);
HTTP_req = ""; // finished with request, empty string
break;
}
// every line of text received from the client ends with \r\n
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}
void ProcessCheckbox(EthernetClient cl)
{
int t2 = 0;
pinMode(13, OUTPUT);
{
cl.println("<input type="text" name="t1"");
cl.println ("<input type="submit"value="ENTER"onclick=fun()>");
function fun()
{
alert("Number is :+t1.value")
t1=t2;
if(t2=1)
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
else
if(t2=0)
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
}
}
}