Hi, i'm making an app to control my shutters with an Arduino Mega. It's got an ethernet shield so it can connect to my local network, wich makes it easy to control it from anywhere.
In the code I use both the ethernet library and also a json library named ArduinoJson (https://arduinojson.org/). I use this to sent all the variables in one package between the Arduino and my phone. The code is based upon the webserver example from the ethernet library.
Here it is:
#include <ArduinoJson.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 177);
EthernetServer server(80);
StaticJsonDocument<5000> doc;
void setup()
{
pinMode(34, OUTPUT);
Ethernet.init(10);
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
DeserializationError error = deserializeJson(doc, c);
if(error) {
Serial.print("deserializeJson() failed with code ");
Serial.println(error.c_str());
return false;
}
int slider = doc["seekBarValue"];
if(slider > 0)
{
digitalWrite(34, HIGH);
delay(2000);
digitalWrite(34, LOW);
delay(2000);
}
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
However, when I try to compile it, I get this error message:
exit status 1
Fout bij het compileren voor board Arduino/Genuino Mega or Mega 2560
I don't know whats causing it and have checked everything from newer versions to the library's and every letter in my code.
Can someone please help.
Spacehack