#include "CayenneDefines.h"
#include "CayenneWiFi.h"
#include "CayenneWiFiClient.h"
#include <Adafruit_NeoPixel.h>
#define CAYANNE_DEBUG
#define CAYANNE_PRINT Serial
#define PIN 4 // LED DATA PIN
int colordelay = 0;
int red, green, blue, brightness = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = ""; // Insert your token here
char ssid[] = ""; // Insert your SSID here
char pwd[] = ""; // Insert your SSID password here
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Cayenne.begin(token, ssid, pwd);
strip.begin();
strip.show();
}
CAYENNE_IN(V6)
{
red = getValue.asInt(); //Get the color from the slider
}
CAYENNE_IN(V7)
{
green = getValue.asInt(); //Get the color from the slider
}
CAYENNE_IN(V8)
{
blue = getValue.asInt(); //Get the color from the slider
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(3);
}
}
void loop() {
// put your main code here, to run repeatedly:
Cayenne.run();
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, strip.Color(red, green, blue));
// strip.setPixelColor(i, Wheel(shift & 255));
}
strip.show();
}
Comments