#include <Adafruit_NeoPixel.h>
#include <IRremote.hpp>
#define PIN 3 // Which pin on the Arduino is connected to the NeoPixels?
#define IR_RECEIVE_PIN 9 // define IR input pin on Arduino
#define NUMPIXELS 300 // How many NeoPixels are attached to the Arduino? // Popular NeoPixel ring size
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
long FirelastTime = 0;
long IRlastTime = 0;
long TimerlastTime = 0;
int interval;
long IRCode = 0;
long OLDIRCode = 0;
bool FireON = false;
bool FireOFF = false;
byte FireSequence = 0;
void setup()
{
Serial.begin(115200);
while (!Serial); //wait until Serial is established - required on some Platforms
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
pixels.begin(); // INITIALIZE NeoPixels
pixels.show(); // Initialize all pixels to 'off'
interval = 300;
randomSeed(analogRead(0));
}
void SimulateFire (bool On, byte FireSq)
{
byte LightValue[NUMPIXELS * 3];
if (millis() - FirelastTime >= interval)
{
if (On)
{
FireOFF = false;
FirelastTime = millis();
interval = 200;
if (FireSq == 1)
{
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
LightValue[i * 3] = random(200, 255); // 250
LightValue[i * 3 + 1] = random(30, 70); // 50
LightValue[i * 3 + 2] = 0;
}
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, LightValue[i * 3], LightValue[i * 3 + 1], LightValue[i * 3 + 2]);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
if (FireSq == 2)
{
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, 250, 50, 0);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
if (FireSq == 3)
{
interval = random(50, 100);
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
LightValue[i * 3] = random(240, 255); // 250
LightValue[i * 3 + 1] = random(30, 60); // 50
LightValue[i * 3 + 2] = 0;
}
// Switch some lights out
byte LightsOff = random(0, 6);
for (int i = 0; i < LightsOff; i++)
{
byte Selected = random(NUMPIXELS);
LightValue[Selected * 3] = 0;
LightValue[Selected * 3 + 1] = 0;
LightValue[Selected * 3 + 2] = 0;
}
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, LightValue[i * 3], LightValue[i * 3 + 1], LightValue[i * 3 + 2]);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
if (FireSq == 4)
{
interval = random(80);
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
LightValue[i * 3] = 250; //random(240,255); // 250
LightValue[i * 3 + 1] = 50; //random(30,60); // 50
LightValue[i * 3 + 2] = 0;
}
// Switch some lights out if Chance Hit
byte ChanceforLightsOff = random(0, 40);
if (ChanceforLightsOff > 35)
{
byte LightsOff = random(5);
for (int i = 0; i < LightsOff; i++)
{
byte Selected = random(NUMPIXELS);
LightValue[Selected * 3] = 0;
LightValue[Selected * 3 + 1] = 0;
LightValue[Selected * 3 + 2] = 0;
}
}
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, LightValue[i * 3], LightValue[i * 3 + 1], LightValue[i * 3 + 2]);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
if (FireSq == 5)
{
interval = random(150, 200);
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
LightValue[i * 3] = random(240, 255); // 250
LightValue[i * 3 + 1] = random(30, 60); // 50
LightValue[i * 3 + 2] = 0;
}
// Switch some lights darker
byte LightsOff = random(0, 4);
for (int i = 0; i < LightsOff; i++)
{
byte Selected = random(NUMPIXELS);
LightValue[Selected * 3] = random(50, 60);
LightValue[Selected * 3 + 1] = random(5, 10);
LightValue[Selected * 3 + 2] = 0;
}
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, LightValue[i * 3], LightValue[i * 3 + 1], LightValue[i * 3 + 2]);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
if (FireSq == 6)
{
interval = random(80);
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
LightValue[i * 3] = random(240, 255); // 250
LightValue[i * 3 + 1] = random(40, 60); // 50
LightValue[i * 3 + 2] = 0;
}
// Switch some lights out if Chance Hit
byte ChanceforLightsOff = random(0, 40);
if (ChanceforLightsOff > 35)
{
byte LightsOff = random(5);
for (int i = 0; i < LightsOff; i++)
{
byte Selected = random(NUMPIXELS);
LightValue[Selected * 3] = 0;
LightValue[Selected * 3 + 1] = 0;
LightValue[Selected * 3 + 2] = 0;
}
}
for (int i = 0; i < NUMPIXELS; i++)
{ // For each pixel...
pixels.setPixelColor(i, LightValue[i * 3], LightValue[i * 3 + 1], LightValue[i * 3 + 2]);
}
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
}
}
else
{
if (!(FireOFF))
{
pixels.clear();
noInterrupts();
pixels.show(); // Send the updated pixel colors to the hardware.
interrupts();
FireOFF = true;
}
}
}
}
long ReceiveIrCommand ()
{
long result = 0;
if (IrReceiver.decode())
{
IrReceiver.resume(); // Receive the next value
return result;
}
return 0 ;
}
void IRCommandProcessor (long IrCommand)
{
if (IRCode == OLDIRCode) {
TimerlastTime = millis(); //Some stuff about debouncing IR Remote
}
if (millis() - TimerlastTime >= 300) {
OLDIRCode = 0 ; //Some stuff about debouncing IR Remote
}
if ((IRCode < -1) & (IRCode != OLDIRCode)) // Valid IR Signal Received
{
OLDIRCode = IRCode; //Some stuff about debouncing IR Remote
switch (IRCode)
{
case -522182433: // In my case 1 on my TV - Remote
{
FireON = !FireON;
FireSequence = 1;
}
break;
case -522149793: // In my case 2 on my TV - Remote
{
FireON = !FireON;
FireSequence = 2;
}
break;
case -522166113: // In my case 3 on my TV - Remote
{
FireON = !FireON;
FireSequence = 3;
}
break;
case -522186513: // In my case 4 on my TV - Remote
{
FireON = !FireON;
FireSequence = 4;
}
break;
case -522153873: // In my case 5 on my TV - Remote
{
FireON = !FireON;
FireSequence = 5;
}
break;
case -522170193: // In my case 6 on my TV - Remote
{
FireON = !FireON;
FireSequence = 6;
}
break;
default:
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); // Print "old" raw data
IrReceiver.printIRResultShort(&Serial); // Print complete received data in one line
IrReceiver.printIRSendUsage(&Serial); // Print the statement required to send this data
break;
}
}
}
void loop()
{
IRCode = ReceiveIrCommand();
IRCommandProcessor(IRCode);
SimulateFire(FireON, FireSequence);
}
ich hab die befehle jetzt angepasst aber etwas machen tut er jetzt immer noch nicht……er zeigt mkr nichtmal mehr etwas im seriellen monitor an