Skip to content

Instantly share code, notes, and snippets.

@HarshiRambhia
Last active December 8, 2022 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HarshiRambhia/62ffc02c3a54b8bd5eeeec8ed9bcd5b1 to your computer and use it in GitHub Desktop.
Save HarshiRambhia/62ffc02c3a54b8bd5eeeec8ed9bcd5b1 to your computer and use it in GitHub Desktop.
Cloud
#include <FastLED.h>
// LED stuff
#define DATA_PIN 3
#define NUM_LEDS 550
//#define MAX_POWER_MILLIAMPS 250
#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;
const int chunkSize = 20;
void moveLEDS (CRGB colour) {
for (int i=0; i<chunkSize; i++) {
// move all LEDs over one, except the first pixel
int count = 219;
for (int j=count; j>1; j--) {
Serial.println(j);
leds[j] = leds[j-1];
}
// set first pixel to new emotion:
leds[0] = colour;
}
FastLED.show();
}
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);
//This tells the library that there's a strand of led on pin 6
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
//FastLED.setMaxPowerInVoltsAndMilliamps( 5, MAX_POWER_MILLIAMPS);
//set master brightness control
FastLED.setBrightness(50);
FastLED.clear();
FastLED.show();
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CHSV(160,80,100);
}
FastLED.show();
}
Serial.begin(9600);
}
void loop() {
//if message is happy
if (digitalRead (buttonHappy) == LOW)
{
moveLEDS (CRGB::Magenta);
}
//if message is soso
else if (digitalRead (buttonSoso) == LOW)
{
moveLEDS (CRGB::Yellow);
}
//if message is sad
else if (digitalRead (buttonSad) == LOW)
{
moveLEDS (CRGB::Cyan);
}
}
#include <FastLED.h>
// LED stuff
#define DATA_PIN 3
#define NUM_LEDS 500
#define MAX_POWER_MILLIAMPS 250
#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 = 20;
void moveLEDS (CRGB colour) {
for (int i=0; i<chunkSize; i++) {
// move all LEDs over one, except the first pixel
int count = 219;
for (int j=count; j>1; j--) {
Serial.println(j);
leds[j] = leds[j-1];
}
// set first pixel to new emotion:
leds[0] = colour;
FastLED.show();
//leds[0] = CRGB::Magenta;
}
//FastLED.show();
}
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);
//This tells the library that there's a strand of led on pin 6
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setMaxPowerInVoltsAndMilliamps( 5, MAX_POWER_MILLIAMPS);
//set master brightness control
FastLED.setBrightness(40);
FastLED.clear();
FastLED.show();
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)
{
moveLEDS (CRGB::Magenta);
//fill_solid(leds + startNumber, 20, CRGB::Magenta); //first 20 LEDs
//FastLED.show();
//delay(2000);
//startNumber = (startNumber + 20);
}
//if message is soso
else if (digitalRead (buttonSoso) == LOW)
{
fill_solid(leds + startNumber, 20, CRGB::Orange); //first 20 LEDs
FastLED.show();
delay(2000);
startNumber = (startNumber + 20);
}
//if message is sad
else if (digitalRead (buttonSad) == LOW)
{
fill_solid(leds + startNumber, 20, CRGB::Red); //first 20 LEDs
FastLED.show();
delay(2000);
startNumber = (startNumber + 20);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment