#include <Adafruit_NeoPixel.h>
#include <stdlib.h>
#include <IRremote.h>
#include “IRRemoteControl.h”
#include <FastLED.h>
#define RECV_PIN 11
#define NEO_PIN 9
#define NUM_LEDS 16
#define COLOR_ORDER GRB
#define SPEEDO 50
#define STEPS 1
int BRIGHTNESS = 255;
int HUE = 0;
int SATURATION = 255;
CRGB leds[NUM_LEDS];
// Creates an Adafruit_NeoPixel instance
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, NEO_PIN, NEO_GRB + NEO_KHZ800);
uint8_t status = 1; // Strip state: ON/OFF
uint32_t lastColor; // Current color on the strip
uint16_t offset = 0; // Used in the raindow function
long timeRef; // Used for measuring delay in the A-B-C sequences
// Creates an IRRemoteControl instance
IRRemoteControl remote(RECV_PIN);
CRGBPalette16 currentPalette;
TBlendType currentBlending;
void setup()
{ delay( 3000 ); // power-up safety delay
initStrip();
remote.enable(); // Starts the receiver
remote.pair(BRIGHT, brightnessup);
remote.pair(DIM, brightnessup);
remote.pair(ON, power); // Pairs buttons to functions
remote.pair(OFF, power);
remote.pair(RED, red);
remote.pair(GREEN, green);
remote.pair(BLUE, blue);
remote.pair(WHITE, white);
remote.pair(REDORANGE, redorange);
remote.pair(LIGHTGREEN, lightgreen);
remote.pair(LIGHTBLUE, lightblue);
remote.pair(ORANGE, orange);
remote.pair(TEAL, teal);
remote.pair(PURPLE, purple);
remote.pair(YELLOWORANGE, yelloworange);
remote.pair(SEABLUE, seablue);
remote.pair(MAGENTA, magenta);
remote.pair(YELLOW, yellow);
remote.pair(OCEANBLUE, oceanblue);
remote.pair(PINK, pink);
remote.pair(SMOOTH, runrainbow);
/*remote.pair(STROBE, strobe);
remote.pair(FLASH, flash);
remote.pair(FADE, fade);*/
FastLED.addLeds<WS2812B, NEO_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentBlending = BLEND;
}
void loop()
{
// Checks if a button is pressed
// and executes the corresponding function
remote.check();
// Optional: Do your thing here. Just keep it short ;)
}
// Initializes the LED strip
void initStrip()
{
strip.begin();
lastColor = strip.Color(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS);
setColor(lastColor);
strip.show();
}
// Turns the LED strip on and off
// When turning on, the color from the last operation appears
void power()
{
if ( status )
{
setColor(strip.Color(0, 0, 0));
status = 0;
}
else
{
setColor(lastColor);
status = 1;
}
}
void red()
{
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.show();
}
void green()
{
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.show();
}
void blue()
{
fill_solid(leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
}
void white()
{
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.show();
}
void redorange()
{
fill_solid(leds, NUM_LEDS, CRGB::OrangeRed);
FastLED.show();
}
void lightgreen()
{
fill_solid(leds, NUM_LEDS, CRGB::LimeGreen);
FastLED.show();
}
void lightblue()
{
fill_solid(leds, NUM_LEDS, CRGB::Indigo);
FastLED.show();
}
void orange()
{
fill_solid(leds, NUM_LEDS, CRGB::Orange);
FastLED.show();
}
void teal()
{
fill_solid(leds, NUM_LEDS, CRGB::Aqua);
FastLED.show();
}
void purple()
{
fill_solid(leds, NUM_LEDS, CRGB::Purple);
FastLED.show();
}
void yelloworange()
{
fill_solid(leds, NUM_LEDS, CRGB::Goldenrod);
FastLED.show();
}
void seablue()
{
fill_solid(leds, NUM_LEDS, CRGB::Teal);
FastLED.show();
}
void magenta()
{
fill_solid(leds, NUM_LEDS, CRGB::Magenta);
FastLED.show();
}
void yellow()
{
fill_solid(leds, NUM_LEDS, CRGB::Yellow);
FastLED.show();
}
void oceanblue()
{
fill_solid(leds, NUM_LEDS, CRGB::MidnightBlue);
FastLED.show();
}
void pink()
{
fill_solid(leds, NUM_LEDS, CRGB::Pink);
FastLED.show();
}
void rainbow() { //-m2-FADE ALL LEDS THROUGH HSV RAINBOW
HUE++;
if (HUE > 255) {HUE = 0;}
for(int idex = 0 ; idex < NUM_LEDS; idex++ ) {
leds[idex] = CHSV(HUE, 255, 255);
}
LEDS.show();
delay(SPEEDO);
}
void runrainbow() {
int r = 10;
for(int i=0; i<r*100; i++) {
rainbow();
}
}j
//this bit is in every palette mode, needs to be in there just once
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = BRIGHTNESS;
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 1;
}
}
void brightnessup() {
BRIGHTNESS++;
if (BRIGHTNESS > 6) BRIGHTNESS = 1;
switch (BRIGHTNESS) {
case 1: LEDS.setBrightness(8); FastLED.show(); break; // 25% - default
case 2: LEDS.setBrightness(16); FastLED.show(); break; // 50%
case 3: LEDS.setBrightness(32); FastLED.show(); break; // 100%
case 4: LEDS.setBrightness(64); FastLED.show(); break; // 3%
case 5: LEDS.setBrightness(128); FastLED.show(); break; // 6%
case 6: LEDS.setBrightness(255); FastLED.show(); break; // 12%
}
}
void brightnessdown() {
BRIGHTNESS–;
if (BRIGHTNESS > 6) BRIGHTNESS = 1;
switch (BRIGHTNESS) {
case 1: LEDS.setBrightness(255); FastLED.show(); break; // 25% - default
case 2: LEDS.setBrightness(128); FastLED.show(); break; // 50%
case 3: LEDS.setBrightness(64); FastLED.show(); break; // 100%
case 4: LEDS.setBrightness(32); FastLED.show(); break; // 3%
case 5: LEDS.setBrightness(16); FastLED.show(); break; // 6%
case 6: LEDS.setBrightness(8); FastLED.show(); break; // 12%
}
}
// Fills the strip with the given color
void setColor(uint32_t c)
{
for (uint16_t i = 0; i < strip.numPixels(); ++i)
strip.setPixelColor(i, c);
strip.setBrightness(BRIGHTNESS);
strip.show();
}