Hallo,
ich verwende eine Arduino Mega mit dem Ethernet Switch V4.06 Code von http://www.instructables.com/id/Ethernet-Switching-with-Arduino/step3/Ethernet-Switching-Version-406/
if (client.available()) {
//if header was not set send it
//read user input
char c = client.read();
if(c == '*'){
printHtmlHeader(client); //call for html header and css
printLoginTitle(client);
printHtmlFooter(client);
//sentHeader = true;
break;
}
if(!sentHeader){
printHtmlHeader(client); //call for html header and css
printHtmlButtonTitle(client); //print the button title
//This is for the arduino to construct the page on the fly.
sentHeader = true;
}
//read user input
// char c = client.read();
//if there was reading but is blank there was no reading
if(reading && c == ' '){
reading = false;
}
//if there is a ? there was user input
if(c == '?') {
reading = true; //found the ?, begin reading the info
}
// if there was user input switch the relevant output
if(reading){
//if user input is H set output to 1
if(c == 'H') {
outp = 1;
}
//if user input is L set output to 0
if(c == 'L') {
outp = 0;
}
Serial.print(c); //print the value of c to serial communication
//Serial.print(outp);
//Serial.print('\n');
switch (c) {
case '0':
//add code here to trigger on 0
triggerPin(outputAddress[0], client, outp);
break;
case '1':
//add code here to trigger on 1
triggerPin(outputAddress[1], client, outp);
break;
case '2':
//add code here to trigger on 2
triggerPin(outputAddress[2], client, outp);
break;
case '3':
//add code here to trigger on 3
triggerPin(outputAddress[3], client, outp);
break;
case '4':
//add code here to trigger on 4
triggerPin(outputAddress[4], client, outp);
break;
case '5':
//add code here to trigger on 5
triggerPin(outputAddress[5], client, outp);
//printHtml(client);
break;
case '6':
//add code here to trigger on 6
triggerPin(outputAddress[6], client, outp);
break;
case '7':
//add code here to trigger on 7
triggerPin(outputAddress[7], client, outp);
break;
case '8':
//add code here to trigger on 8
triggerPin(outputAddress[8], client, outp);
break;
case '9':
//add code here to trigger on 9
triggerPin(outputAddress[9], client, outp);
break;
} //end of switch case
Ich würde gerne mehr als 10 Ausgänge festlegen, doch habe Probleme wenn ich case '10', case '11';, etc verwende.
Habe es schon mit if probiert, komme aber zu keinem guten Ergebnis.
Auch wenn ich
case '22':
//add code here to trigger on 7
triggerPin(outputAddress[7], client, outp);
break;
bis
case '31':
//add code here to trigger on 7
triggerPin(outputAddress[7], client, outp);
break;
verwende funktioniert alles, aber ab 32 kommen wieder folgende Probleme:
error: duplicate case value.
Ich bin noch Anfänger :D, kann mir jemand dabei helfen?
So schwer kann es doch eigentlich nicht sein, oder?
Danke
JulHa