Hi all!
I’m currently trying to make a Photon control a [NeoPixel ring][1] designed to work with the Core/Photon. The basic idea is that I want it to change colors based on a tweet with a specific hashtag used in it. The two examples that I have right now are #Red and #Blue.
So I’m using IFTTT and DO to send tweets and retrieve them. Press a DO Button to send a tweet with #Red and a time stamp, and have IFTTT listening for the tweet with #Red. When IFTTT gets the tweet, it should call a function on my Photon, which in turn would change what color the LED ring is.
The problem I’m having here is that when IFTTT receives my tweet, it doesn’t send anything to my Photon. It gives me a “Particle Action Error” in the log of the recipe, so it must be an issue with my code. Can anyone help me look it over?
#include "neopixel/neopixel.h"
#define PIXEL_PIN D6
#define PIXEL_COUNT 24
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int colorSet(String command); //This is for the function in the IFTTT cloud
int colorval; //colorval is used in the loop to determine which color is set on the ring
void setup()
{
Particle.function("set color", colorSet); //This names the function to be retrieved when making an IFTTT recipe.
strip.begin(); // Initialize the strip
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(100); // Set brightness limit (value between 0-255)
}
void loop()
{
if(colorval = 1)
{
colorAll(strip.Color(255, 100, 0), 50);
}
else if(colorval = 2)
{
colorAll(strip.Color(0, 0, 255), 50);
}
}
int colorSet(String command) // This section is where it checks what has been sent from the cloud. Recipes will get
{
if(command == "red")
{
colorval = 1;
}
if(command == "blue")
{
colorval = 2;
}
else return 1337;
}
// This is from the NeoPixel example library.
void colorAll(uint32_t c, uint8_t wait) {
uint16_t i;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.show();
delay(wait);
}
Any help is appreciated! Thanks
[1]: https://www.adafruit.com/products/2268