我正试图将Arduino的LED引脚13转换为表格贴上的HIGH。当我提交表格时,LED没有任何反应;它保持不动。我错过了什么吗?我正在使用Webduino库。
void setup()
{
// set LED to OUTPUT
pinMode(13, OUTPUT);
Ethernet.begin(mac, ip);
webserver.begin();
webserver.setDefaultCommand(&defaultCmd);
webserver.addCommand("form", &formCmd);
}
void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
outputIndex(server, type);
}
void outputIndex(WebServer &server, WebServer::ConnectionType type)
{
P(htmlHead) =
"<html><head><title>Door Manager</title></head><body>";
server.httpSuccess();
server.printP(htmlHead);
server << "<form action='" PREFIX "/form' method='post'>";
server << "<input type='submit' value='LED HIGH' /></form>";
server << "</body></html>";
}
void formCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
// POST
if (type == WebServer::POST)
{
digitalWrite(13, HIGH);
// redirect to GET to this same action
server.httpSeeOther(PREFIX "/form");
}
else // GET
outputIndex(server, type);
}