Skip to content

Instantly share code, notes, and snippets.

@ericjforman
Forked from HarshiRambhia/New+OldCode.ino
Last active December 8, 2022 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericjforman/a3aa2773e114dadadbf0fd092f806bee to your computer and use it in GitHub Desktop.
Save ericjforman/a3aa2773e114dadadbf0fd092f806bee to your computer and use it in GitHub Desktop.
Cloud
#include <FastLED.h>
// LED stuff
#define DATA_PIN 3
#define NUM_LEDS 30 // 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() {
// 3 second delay for boot recovery, and a moment of silence
delay(3000);
//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(40);
FastLED.clear();
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();
*/
Serial.begin(9600);
}
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(200); // TEMPORARY DELAY TO SEE WHAT IS HAPPENING
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment