Trying to make my photon particle pull from my twitter and flash a Neopixel based on the hashtag in my tweet. Right now, it’s turning each LED on one by one instead of flashing. I’ve been trying to figure out how to use a loop with the Spark.functio but from what I understand I need the ‘int’ for each tweet function. (Correct me if I’m wrong please!)
Anyone know what I can do?
#include "neopixel.h"
#include <math.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D0
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int pixel_position = 0;
int blinkNum = 10;
int blinkSpeed = 10;
void setup() {
Serial.begin( 9600 );
strip.begin();
strip.show(); //Initialize all pixels to 'off'
Spark.function("sad", sadtweet);
Spark.function("mad", madtweet);
Spark.function("glad", gladtweet);
Spark.function("off", offtweet);
}
int sadtweet(String cmd) {
for(int j = 0; j < blinkNum*2; j++) {
if(j % 2 == 0) {
for(int i = 0; i < strip.numPixels(); i++){
strip.setPixelColor(i, 0, 0, 255);
strip.show();
delay(1000/blinkSpeed);
}
}
}
}
int madtweet(String cmd) {
for(int j = 0; j < blinkNum*2; j++) {
if(j % 2 == 0) {
for(int i = 0; i < strip.numPixels(); i++){
strip.setPixelColor(i, 255, 0, 0);
strip.show();
delay(1000/blinkSpeed);
}
}
}
}
int gladtweet(String cmd){
for(int j = 0; j < blinkNum*2; j++) {
if(j % 2 == 0) {
for(int i = 0; i < strip.numPixels(); i++){
strip.setPixelColor(i, 255, 255, 50);
strip.show();
delay(1000/blinkSpeed);
}
}
}
}
int offtweet(String cmd){
strip.Color(0,0,0); // Blue
}