#include <FastLED.h>
// LED stuff
#define DATA_PIN 3
#define NUM_LEDS 16 // will be 500
#define MAX_POWER_MILLIAMPS 6000
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
//buttons
const int buttonHappy = 7;
const int buttonSoso = 6;
const int buttonSad = 5;
//variable for start number, originally set to 0
int startNumber = 0;
const int chunkSize = 3; // will be 20
void setup() {
Serial.begin(9600);
Serial.println("begin");
// 3 second delay for boot recovery, and a moment of silence
delay(1000);
//buttons
pinMode(buttonHappy,INPUT_PULLUP);
pinMode(buttonSoso,INPUT_PULLUP);
pinMode(buttonSad,INPUT_PULLUP);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setMaxPowerInVoltsAndMilliamps( 5, MAX_POWER_MILLIAMPS);
FastLED.setBrightness(255);
FastLED.clear();
delay(1000);
FastLED.show();
// initial color fill:
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Seashell;
//leds[i] = CHSV(160,80,100);
}
FastLED.show();
}
void loop() {
//if message is happy
if (digitalRead (buttonHappy) == LOW)
{
Serial.println("happy...");
moveLEDS (CRGB::Magenta);
}
//if message is soso
else if (digitalRead (buttonSoso) == LOW)
{
Serial.println("so so...");
moveLEDS (CRGB::Orange);
}
//if message is sad
else if (digitalRead (buttonSad) == LOW)
{
Serial.println("sad...");
moveLEDS (CRGB::Red);
}
}
void moveLEDS (CRGB colour) {
for (int i=0; i<chunkSize; i++) {
Serial.print("chunk LED ");
Serial.println(i);
// move all LEDs over one, except the first pixel
for (int j=NUM_LEDS-1; j>=1; j--) {
//Serial.println(j);
leds[j] = leds[j-1];
}
// set first pixel to new emotion:
leds[0] = colour;
FastLED.show();
delay(50); // TEMPORARY DELAY TO SEE WHAT IS HAPPENING
}
}