Created
January 21, 2018 20:43
-
-
Save wmontg5988/ecadb1b394b959ef78485fe84b82e8c2 to your computer and use it in GitHub Desktop.
wemos code to control lights with slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space | |
#include <CayenneMQTTESP8266.h> | |
// WiFi network info. | |
char ssid[] = “********”; | |
char wifiPassword[] = “*******”; | |
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard. | |
char username[] = “"; | |
char password[] = "”; | |
char clientID[] = “************”; | |
unsigned long lastMillis = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Cayenne.begin(username, password, clientID, ssid, wifiPassword); | |
} | |
void loop() | |
{ | |
Cayenne.loop(); | |
} | |
// This function is called when data is sent from Cayenne. | |
CAYENNE_IN(1) | |
{ | |
int value = getValue.asInt(); // 0 to 255 | |
CAYENNE_LOG(“Channel %d, pin %d, value %d”, 1, 5, value); | |
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255. | |
analogWrite(5, value); | |
} | |
CAYENNE_IN_DEFAULT() | |
{ | |
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString()); | |
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment