Hi Everyone,
I made some test with ethernet.h first and then with dimmer_light only. I can do what I want in both cases. But I try to use them at the same time, the webserver is no more working.
In fact, as soon as I add the command line: DimmableLight::begin(); , the webserver is no more working well.
Can someone help me to fix it ?
Do I have to use other librairies ?
Thank you for your help.
// Include the web server
#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoSTL.h>
#include <dimmable_light.h>
//*******************************************
//*******************************************
// DECLARATION
//*******************************************
//*******************************************
//*******************************************
// DIMMER MANAGER
//*******************************************
const int syncPin = 2; //zero pin Set the Zero Cross pin, calling the static method setSyncPin:
const int thyrMur = 3; // command pin pour la lumière contre le mur
const int thyrPremier = 4; // command pin pour la lumière du palier du premier
DimmableLight lightMur(thyrMur);
DimmableLight lightPremier(thyrPremier);
//*******************************************
// WEB SERVER
//*******************************************
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
byte mac[] = { 0x95, 0x8F, 0x91, 0xEF, 0xA2, 0x98 };
IPAddress ip(192,168,1,92);
EthernetServer server(8090);
//*******************************************
// OTHER VARIABLES
//*******************************************
char PARM = ' ' ;
char * PARMALL ;
int DECOUP = 32;
int TMAX = 2000;
float iDelay = 20;
//*******************************************
// DANCE PARAM
int TEMPO = 90; // in BPM
unsigned long PROCTIME; // in milliseconds -- 90 BPM = 90/60 BPS = 90/60000 BPmillis
// unsigned long MUSICTIME;
//*******************************************
//*******************************************
// SETUP
//*******************************************
//*******************************************
void setup() {
pinMode(5, OUTPUT); // Inter lumière plafond salon
pinMode(6, OUTPUT); // Inter lumière mur salon
pinMode(7, OUTPUT); // Inter lumière premier palier
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
//*******************************************
// DIMMER
//*******************************************
DimmableLight::setSyncPin(syncPin);
// VERY IMPORTANT: Call this method to activate the library
DimmableLight::begin();
lightMur.setBrightness(110);
Serial.println("Done!");
//*******************************************
// WEB SERVER
//*******************************************
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
//*******************************************
// OTHER
//*******************************************
// PROCTIME = millis();
PARM = ' ';
// pmRepos();
Serial.println("Initialisation finie");
} // Fin SETUP
void loop() {
char req[1024];
int index = 0;
// 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.print("read : ");
//Serial.println(index);
req[index++] = c;
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
req[index] = 0;
index=0;
PARM = req[5] ;
PARMALL = req;
Serial.print("PARM 1: ");
Serial.println(PARM);
if (PARM == 'a')
{ Serial.println("on a recu un a");
//manuallyMove(PARMALL);
Serial.println("on sort de manually"); }
// 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>");
client.print("Requete recue : ");
client.println(req[5]);
// output the value of each analog input pin
client.println("</html>");
break;
}
// Serial.println("WHILE RECEIVE");
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(1000);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}