#define WIFI_NAME "wifi" #define WIFI_PASSWORD "pass" #define DEVICE_ID 1 #define DEVICE_NAME "Arduino LED" #define TOKEN "~155_45678i9oDFGHJ" #include #include #include #include #include ESP8266WiFiMulti WiFiMulti; RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID); uint8_t R = D5;//New uint8_t G = D6;//New uint8_t B = D7;//New uint8_t singleLed = D1;//New //*************** CODE FOR CONFORTABLE VARIABLE SET ********************* inline void setRgbLed(int16_t i1, int16_t i2, int16_t i3) {remoteMe.getVariables()->setSmallInteger3("rgbLed", i1, i2, i3); } inline void setSingleLed(boolean b) {remoteMe.getVariables()->setBoolean("singleLed", b); } //*************** IMPLEMENT FUNCTIONS BELOW ********************* void onSingleLedChange(boolean b) { digitalWrite(singleLed, b ? HIGH : LOW);//New } void onRgbLedChange(int16_t i1, int16_t i2, int16_t i3) { analogWrite(R,1023-i1);//New analogWrite(G,1023-i2);//New analogWrite(B,1023- i3);//New } void setup() { WiFiMulti.addAP(WIFI_NAME, WIFI_PASSWORD); while (WiFiMulti.run() != WL_CONNECTED) { delay(100); } remoteMe.setupTwoWayCommunication(); remoteMe.sendRegisterDeviceMessage(DEVICE_NAME); remoteMe.getVariables()->observeSmallInteger3("rgbLed" ,onRgbLedChange); remoteMe.getVariables()->observeBoolean("singleLed" ,onSingleLedChange); pinMode(R, OUTPUT);//New pinMode(G, OUTPUT);//New pinMode(B, OUTPUT);//New pinMode(singleLed, OUTPUT);//New } void loop() { remoteMe.loop(); }