Hello.I have a led strip and I want to fade in and fade out the strip with yellow color (RGB = (255,255,0) ).
I use 1 for-loop to fade in and 1 for-loop to fade out,but the color changes,but I want to change only brightness,not color.
I asked in arduino forum, and told me that I need a function to convert Hue, Saturation, Value (HSV) into RGB.I searched a lot of time,but I didn't find anything,just some complicated functions.
Can anyone suggest me some link using HSV->RGB ,or does anyone know how to solve my problem?
(I want to fade in and fade out yellow color from 0->255 and 255->0 ,but intermediate color changes.)
Before ask in arduino forum,I made this without success as I said:
What I have tried:
#define REDcolor 5
#define GREENcolor 3
#define BLUEcolor 6
int *BrightnessValue = NULL;
void setup()
{
pinMode(REDcolor, OUTPUT);
pinMode(GREENcolor, OUTPUT);
pinMode(BLUEcolor, OUTPUT);
}
void loop()
{
for(*BrightnessValue = 0; *BrightnessValue < 255; (*BrightnessValue)++ )
{
yellow_color();
delay(15);
}
for(*BrightnessValue = 255; *BrightnessValue > 0; (*BrightnessValue)-- )
{
yellow_color();
delay(15);
}
}
void brightness(int b_value)
{
BrightnessValue = &b_value;
}
void getColor(int red_value , int green_value , int blue_value) {
analogWrite(REDcolor, 255 - red_value);
analogWrite(GREENcolor , 255 - green_value);
analogWrite(BLUEcolor , 255 - blue_value);
}
void blue_color()
{
getColor(0 , 0 , *BrightnessValue);
}
void red_color()
{
getColor(*BrightnessValue , 0 , 0);
}
void green_color()
{
getColor(0 , *BrightnessValue , 0);
}
void white_color()
{
getColor(*BrightnessValue , *BrightnessValue , *BrightnessValue);
}
void cyan_color()
{
getColor(0 , *BrightnessValue , *BrightnessValue);
}
void yellow_color()
{
getColor(200 , 20 , 0);
}
void fuchsia_color()
{
getColor(*BrightnessValue , 0 , *BrightnessValue);
}
Thanks a lot.
Any help would be appreciated.