Hi. I have been using Arduino for only a little while now, so I don't understand everything about it quite yet. I've been experimenting with the NodeMCU board. I put the board link into File/Preferences, then downloaded esp8266 by ESP8266 Community from the board manager Tools/Board/Board Manager. I also downloaded the ESP8266WiFi library. It came in a bundle of other ESP8266 libraries, but I only used ESP8266WiFi in my code. My code is supposed to create a site where I can click an "on" or "off" button to control and LED attached to the NodeMCU.
Code:
#include <ESP8266WiFi.h>
const char* ssid = "SSID";
const char* password = "PASSWORD";
WiFiServer server(80);
int value = LOW;
int ledPin = 2;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("CONNECTED");
server.begin();
Serial.println("STARTEd");
Serial.print("CLICK: http://");
Serial.print(WiFi.localIP());
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
if (request.indexOf("ON") > 0)
value = HIGH;
if (request.indexOf("OFF") > 0)
value = LOW;
digitalWrite(ledPin, value);
//******* WEBSITE ***************
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if (value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("<br><br>");
client.println("<a href=\"/LED=ON\"><button>Turn On </button></a>");
client.println("<a href=\"/LED=OFF\"><button>Turn Off </button></a><br />");
client.println("</html>");
}
For some reason, this doesn't upload and I get this error:
Please help, I don't understand this at all.
Apparently the forums thinks my error message is a bunch of links and says i can't have more than two so I made this document
It is a better post of the issue including links and error.