#define WIFI_NAME "home" #define WIFI_PASSWORD "passwrodtowifi" #define DEVICE_ID 2 #define DEVICE_NAME "ArduinoWithButtons" #define TOKEN "~155_D49LDj@aBFXK." #include #include #include #include #include #include boolean currentState=false; // New uint8_t LEDpin = D5;// New RBD::Button button1(D1);// New RBD::Button button2(D2);// New ESP8266WiFiMulti WiFiMulti; RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID); //*************** 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 onRgbLedChange(int16_t i1, int16_t i2, int16_t i3) { //your code here } void onSingleLedChange(boolean b) { currentState=b;// New digitalWrite(LEDpin, b ? HIGH : LOW);// 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(LEDpin, OUTPUT);// New } void loop() { remoteMe.loop(); if (button1.onPressed()) {// New setSingleLed(!currentState);// New }// New if (button2.onPressed()) {// New setRgbLed(random(1024),random(1024),random(1024));// New }// New }