Hallo,
ich habe einen Webserver erstellt über den man ein Codeschloss öffnen kann. Nun möchte ich als Zusatzfunktion noch eine automatisch generierte Zahl im Webserver anzeigen. Wie die "Zufallszahl" erzeugt wird, ist mir bekannt, mein Problem ist nur das ich es einfach nicht hinbekomme den Wert einer Variablen (char) im Webserver darzustellen. Kann mir hierbei jemand Helfen?? Hier ist der aktuelle Code für den Webserver, die Stelle wo die Zufallszahl angezeigt werden soll ist markiert (ganz unten)
Gruß,
Tobi
void Webserver(){
EthernetClient myClient = myServer.available();
if (myClient) {
while (myClient.connected()) {
if (myClient.available()) {
char c = myClient.read();
if (readString.length() < 100)
{
readString += c;
}
Serial.print(c);
if (c == '\n') {
if(readString.indexOf("aktion=AUF")>0)
{
digitalWrite(TuerPin, HIGH); // Türöffner an
TUERON = true;
}
if(readString.indexOf("aktion=ZU")>0)
{
//Tüeröffner OFF
digitalWrite(TuerPin, LOW); //Tür zu
TUERON = false;
}
if(readString.indexOf("aktion=AUTO")>0)
{
//Türöffner im Automatikbetrieb
digitalWrite(TuerPin,HIGH);
delay(40000);
digitalWrite(TuerPin,LOW);
}
myClient.println("HTTP/1.1 200 OK");
myClient.println("Content-Type: text/html");
myClient.println();
myClient.print("<body style=background-color:powderblue>");
myClient.println(" <font face=arial color='navy'><h1 style='text-align:center'>JUMO GmbH & Co.KG Fulda</font></h1>");
myClient.println("<font face=arial color='navy'><h2 style='text-align:center'>Ausbildungszentrum - Elektrotechnik</font></h2>");
myClient.print("<hr noshade width='100%' size='5' align='left' color='navy'>");
delay(1); // Kurze Pause für Web-Browser
myClient.println("<font face=arial color='navy'><h4> manuelle Bedienung :</font></h4>");
myClient.print("<form method=get name=TUER><input type=submit name=aktion value=AUF></form>");
myClient.print("<form method=get name=TUER><input type=submit name=aktion value=ZU></form>");
if (TUERON){
//myClient.print("<form method=get name=TUER><input type=submit name=aktion value=AUF></form>");
//myClient.print("<form method=get name=TUER><input type=submit name=aktion value=ZU></form>");
// myClient.print("<br />");
}
if (TUERON){
myClient.print("<font face=arial color='navy' size='2'>Die Lagertuer ist aktuell<font color='red' size='2'> geoeffnet");
myClient.print("<br/>");
myClient.print("<font face=arial color='navy' size='2'>ZU druecken um die Tuere zu schliessen");
}
else{
myClient.print("<font face=arial color='navy' size='2'>Die Lagertuer ist aktuell<font color='red' size='2'> geschlossen ");
myClient.print("<br/>");
myClient.print("<font face=arial color='navy' size='2'>AUF druecken um die Tuere zu oeffnen");
myClient.print("<br />");
}
myClient.print("<hr noshade width='100%' size='5' align='left' color='navy'>");
myClient.println("<font face=arial color='navy'> <h3> Automatikmodus :</font></h3>");
myClient.print("<form method=get name=TUER><input type=submit name=aktion value=AUTO></form>");
myClient.print("<font face=arial color='navy' size='2'>Durch druecken des Automatik Buttons");
myClient.print("<br/>");
myClient.print("<font face=arial color='navy' size='2'>wird die Tuer fuer<font color='red' size='2' > 40 Sekunden");
myClient.print("<font face=arial color='navy' size='2'> geoeffnet");
// ab hier beginnt der Versuch mit der generierten Zufallszahl
myClient.print("<hr noshade width='100%' size='5' align='left' color='navy'>");
myClient.println("<font face=arial color='navy'> <h3> Einweg-Code :</font></h3>"); // Überschrift für den Zufallscode
// hier muss irgendwie das eingefügt werden was mir die Variable anzeigt
myClient.print("<br/>");
myClient.print("<font face=arial color='navy' size='2'>Nachdem der oben abgebildete Code am Keypad eingegeben");
myClient.print("<br/>");
myClient.print("<font face=arial color='navy' size='2'>wurde, verfaellt er und ein neuer wird generiert.");
myClient.print("<br/>");
readString="";
myClient.stop(); // Client-Verbindung schließen
}
}
}
}
}