Hello,
I struggeling with my new project
I want to use my 433Mhz Remote to change the color of my LED's.
the coding for the 433 part and for the LED's it self is ok and working.
So here the function which does a Rainbow with the LED's
This function will be interrupted.
The problem is in the switchcase part. The setColor function is called (could see a very short change at the LED) but than the programm runs throw with the rainbow function.
But it should stay in this color until the next interrupt appears.
But if it's in HSVCircle i should go throw throw the HSV circle endless
Did someone have an idea how to implement this?
Please see code below
Thanks
Ludger
#include "FastLED.h"
#include "RCSwitch.h"
#define PIN 5 // output on PIN #
#define LED 100 // no. of LED
#define t 100 //14062 // time of circle in ms 14062 /1hour
//1 hour =60min = 3600s = 3600000ms
// 3600000 / 256 =14062 ms/Farbe
RCSwitch mySwitch = RCSwitch();
CRGB leds[LED];
void setup()
{
FastLED.addLeds<NEOPIXEL, PIN>(leds, LED);
//int colorchanger = 0;
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
}
void HSVcircle(int start, int s, int bright)
{
// go throw HSV circle
for (int circle=start; circle<256; circle++)
{
//go throw LED's
for (int i=0; i<LED; i++)
{
leds[i].setHSV(circle+(i/3),s,bright);
}
FastLED.show();
delay(t);
//delay(14062); // one circle an hour
circle++;
if (circle ==255)
{circle=1;}
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
switch (value)
{
case 21585:
{
HSVcircle(1,255,255);
//wait until another interrupt is detected
break;
}
case 21588:
{
setColor(0,0,0);
break;
}
case 21777:
{
setColor(10,255,255);
break;
}
case 21780:
{
setColor(170,255,255);
break;
}
}
mySwitch.resetAvailable();
}
}
}
void setColor( int h, int s, int v)
{
for (int i=0; i<LED; i++)
{
leds[i].setHSV(h,s,v);
}
FastLED.show();
}
i added the setup