#include <IRremote.hpp>
#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>
int receiver = 11;
int Red, Green, Blue, White, Soft, Purple, Power, Brightness, Speed;
int RedAdress = 0;
int GreenAdress = 1;
int BlueAdress = 2;
int BrightnessAdress = 3;
int SpeedAdress = 4;
int PowerAdress = 5;
int Rainbow = 1;
int fadeAmount = 15;
#define LED_PIN 6
#define LED_COUNT 90
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
strip.begin();
Serial.println(" Reading data from EEprom...");
Red = EEPROM.read(RedAdress);
Serial.print("RED VALUE = "); Serial.println(Red);
Green = EEPROM.read(GreenAdress);
Serial.print("GREEN VALUE = "); Serial.println(Green);
Blue = EEPROM.read(BlueAdress);
Serial.print("BLUE VALUE = "); Serial.println(Blue);
Brightness = EEPROM.read(BrightnessAdress);
Serial.print("BRIGHTNESS VALUE = "); Serial.println(Brightness);
Speed = EEPROM.read(SpeedAdress);
if (Speed > 50) Speed = 0;
Serial.print("SPEED VALUE = "); Serial.println(Speed);
Power = EEPROM.read(PowerAdress);
Serial.print("POWER VALUE = "); Serial.println(Power);
strip.setBrightness(255);
if (Power = 1)
{
colorWipe(strip.Color(Red, Green, Blue), Speed);
} else
{
colorWipe(strip.Color(0, 0, 0), 0);
}
strip.show();
};
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
irrecv.resume(); // receive the next value
}
};
void translateIR()
{
switch(results.value)
{
case 0xFF30CF: Serial.println(" 1");
Serial.println(Red);
colorWipe(strip.Color(255, 0, 0), Speed);
strip.show();
break;
case 0xFF18E7: Serial.println(" 2");
Serial.println(Green);
colorWipe(strip.Color(0, 255, 0), Speed);
strip.show();
break;
case 0xFF7A85: Serial.println(" 3");
Serial.println(Blue);
colorWipe(strip.Color(0, 0, 255), Speed);
strip.show();
break;
case 0xFF629D: Serial.println(" VOL_ADD"); break;
case 0xFF22DD: Serial.println(" FAST_BACK");break;
case 0xFF02FD: Serial.println(" PAUSE");break;
case 0xFF10EF: Serial.println(" 4");
Serial.println(White);
colorWipe(strip.Color(255, 255, 255), Speed);
strip.show();
break;
case 0xFF38C7: Serial.println(" 5");
Serial.println(Soft);
colorWipe(strip.Color(235, 100, 5), Speed);
strip.show();
break;
case 0xFF5AA5:
case 0xFFC23D: Serial.println(" 6");
Serial.println(Purple);
colorWipe(strip.Color(144, 9, 181), Speed);
strip.show();
break;
case 0xFF6897: Serial.println(" 0");
rainbow(20);
Rainbow = 50;
break;
case 0xFFA25D: Serial.println("Power");
Serial.println(Power);
colorWipe(strip.Color(0, 0, 0), Speed);
strip.show();
break;
case 0xFF4AB5: Serial.println(" 8");
Speed = Speed - 5;
if (Speed < 0) Speed = 0;
colorWipe(strip.Color(0, 0, 0), 0);
colorWipe(strip.Color(Red, Green, Blue), Speed);
strip.show();
Serial.print("SPEED: ");
Serial.println(Speed);
break;
case 0xFFE01F: Serial.println(" LEFT");
Brightness = Brightness - 25;
if (Brightness < 0) Brightness = 0;
Serial.println(Brightness);
strip.setBrightness(Brightness);
colorWipe(strip.Color(Red, Green, Blue), 0);
strip.show();
break;
case 0xFF9867: Serial.println(" -OK-");
Power = Power + 1;
if (Power > 1) Power = 0 ;
Serial.print("POWER ON STATUS: ");
Serial.println(Power);
break;
case 0xFF906F: Serial.println(" RIGHT");
Brightness = Brightness + 25;
if (Brightness > 255) Brightness = 255;
Serial.println(Brightness);
strip.setBrightness(Brightness);
colorWipe(strip.Color(Red, Green, Blue), 0);
strip.show();
break;
case 0xFFA857: Serial.println(" DOWN");
Speed = Speed + 5;
if (Speed > 50) Speed = 50;
colorWipe(strip.Color(0, 0, 0), 0);
colorWipe(strip.Color(Red, Green, Blue), Speed);
strip.show(); Serial.print("SPEED: ");
Serial.println(Speed);
break;
default:
Serial.println(results.value, HEX);
Serial.println(" other button ");
} // End Case
}
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*10; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}