我正在尝试在表格柱上将 Arduino 的 LED 引脚 13 设置为高电平。当我提交表单时,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);
}