Bonjour , alors voila , je dois réaliser un projet arduino ethernet shield avec micro sd afin de faire un server web , dans la carte SD et le site s'affiche correctement ( sauf fond écran mais je verrais plus tard ) , le site consiste a commander un véhicule , j'aimerai que dès que je clique sur commander , l'arduino récupère les informations sous forme de variables , les stocks , et indique l'heure , la date , le nombre de place et la destination sur le moniteur série pour confirmé que la carte a arduino a bien récupérer les données du site , PS ; c'est très urgent il me reste plus que 5 jours pour terminer se projet , merci a tous alors je vous transmets les codes :
HTML
<table>
<tr>
<td width="150" rowspan="4" style="border-right: 1px solid #ddd;">Choisir vos nombre de place , l'heure et la date : </td>
<th width="200">Heure</th>
<td>
<select name="Heure" id="Heure">
<option value="no">Aucun</option>
<option value="1">08h00</option><option value="5">09h00</option><option value="2">10h00</option><option value="4">11h00</option><option value="8">12h00</option><option value="3">14h00</option><option value="11">15h00</option><option value="6">16h00</option><option value="12">17h00</option><option value="9">18h00</option><option value="10">19h00</option><option value="7">20h</option> </select>
</td>
</tr>
<th width="200">Date</th>
<td>
<select name="Date" id="Date">
<option value="no">Aucun</option>
<option value="3">Lundi</option><option value="11">Mardi</option><option value="6">Mercredi</option><option value="12">Jeudi</option><option value="9">Vendredi</option><option value="10">Samedi</option><option value="7">Dimanche</option> </select>
</td>
</tr>
<tr>
<tr>
<th>Nombre de place</th>
<td>
<select name="Places" id="Places">
<option value="no">Aucune</option>
<option value="1.8">2</option><option value="2.5">3</option><option value="3.5">4</option><option value="Carte">6</option> </select>
</td>
</tr>
</table>
</div>
<div class="post" id="filtre">
<table>
<tr>
<td width="150" rowspan="4" style="border-right: 1px solid #ddd;">Choisir votre emplacement et votre destination : </td>
<th width="200">Emplacement</th>
<td>
<select name="Emplacement" id="Véhicule">
<option value="no">Aucun</option>
<option value="1">Rue de la république</option><option value="5">Place pie</option><option value="2">Auchan</option><option value="4">Cap sud</option><option value="8">Courtine</option><option value="3">Campus philippe de girard</option><option value="11">Villeneuve-les-avignon</option><option value="6">Sorgue</option><option value="12">Le pontet</option><option value="9">Montfavet</option><option value="10">Gare SNCF</option><option value="7">Gare TGV </option> </select>
</td>
</tr>
<tr>
<tr>
<th>Lieu de déstination</th>
<td>
<select name="Places" id="Places">
<option value="no">Aucune</option>
<option value="1">Rue de la république</option><option value="5">Place pie</option><option value="2">Auchan</option><option value="4">Cap sud</option><option value="8">Courtine</option><option value="3">Campus philippe de girard</option><option value="11">Villeneuve-les-avignon</option><option value="6">Sorgue</option><option value="12">Le pontet</option><option value="9">Montfavet</option><option value="10">Gare SNCF</option><option value="7">Gare TGV </option> </select>
</td>
</tr>
</table>
<p align="right" style="padding-right: 12px;"><input class="btn_input" type="submit" value="Commandez" id="Commandez" name="Commandez"></p>
<script language=vbscript>
Set fs = CreateObject("Scripting.FileSystemObject" )
Set a = fs.CreateTextFile("c:\testfile.txt", True) <--ton fichier à créer
a.WriteLine("This is a test." ) <--la,tu mets tes données(fais une boucle for pr ttes les écrires)
a.Close
</script>
</div><!-- #filtre -->
<head>
<meta charset="UTF-8">
<title>Fond extensible - version CSS</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen"/>
</head>
CODE ARDUINO
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Tinywebserver.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x67, 0xFF };
IPAddress ip(192, 168, 0, 12); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80
File webFile;
String HTTP_req = ""; // stores the received HTTP request
void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin(); // start to listen for clients
Serial.begin(115200); // for debugging
// initialize SD card
Serial.println("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("ERROR - SD card initialization failed!");
return; // init failed
}
Serial.println("SUCCESS - SD card initialized.");
// check for index.htm file
if (!SD.exists("index.htm")) {
Serial.println("ERROR - Can't find index.htm file!");
return; // can't find index file
}
Serial.println("SUCCESS - Found index.htm file.");
}
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 HTTP request character
Serial.print(c); // print HTTP request character to serial monitor
// 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("Connnection: close");
client.print("<body style="),client.print(byte(34)); // <body style="
client.print("color: rgb(255, 255, 0); background-color: rgb(0, 0, 255);");
//color: rgb(255, 255, 0); background-color: rgb(0, 0, 255);
client.print(byte(34)),client.print(">") ; // " >
client.println("
");
client.println();
// send web page
if ((HTTP_req.indexOf("GET / ") > -1)
|| (HTTP_req.indexOf("GET /index.htm") > -1)) {
webFile = SD.open("page1.htm"); // open web page file
}
else if (HTTP_req.indexOf("GET /page2.htm") > -1) {
webFile = SD.open("page2.htm"); // open web page file
}
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
HTTP_req = ""; // empty the 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)
}