Answer the question
In order to leave comments, you need to log in
How to implement a smooth change of RGB LED color values?
Hello!
Please tell me how to properly organize a smooth color transfer to the LED.
At the moment, it is implemented in such a way that i takes values from a tuple, transfers them to the tape and falls asleep for N times. However, in this way it turns out not a smooth color change, I want to achieve smoothness. Only G,B values change.
The values increase until the middle of the day, then decrease.
light_color_list = ((255, 109, 0), #R, G, B
(255, 115, 0),
(255, 121, 0),
(255, 126, 0),
(255, 131, 0),
(255, 137, 18),
(255, 142, 33),
(255, 147, 44),
(255, 152, 54),
(255, 157, 63),
(255, 161, 72),
(255, 165, 79),
(255, 169, 87),
(255, 173, 94),
(255, 177, 101),
(255, 180, 107),
(255, 184, 114),
(255, 187, 120),
(255, 190, 126),
(255, 193, 132),
(255, 196, 137),
(255, 199, 143),
(255, 201, 148),
(255, 204, 153),
(255, 206, 159),
(255, 209, 163),
(255, 211, 168),
(255, 213, 173),
(255, 215, 177),
(255, 217, 182),
(255, 219, 186),
(255, 221, 190),
(255, 223, 194),
(255, 225, 198),
(255, 227, 202),
(255, 228, 206),
(255, 230, 210),
(255, 232, 213),
(255, 233, 217),
(255, 235, 220))
def sunset(count, timer):
''' Часть кода намеренно пропущена '''
sleep = (day_length - sec) // len(light_color_list) # Время рассчитывается исходя из длинны дня (может быть разная в зависимости от координат заданных.
while i < parts + 1:
led(light_color_list[i])
i += 1
time.sleep_ms(sleep)
Answer the question
In order to leave comments, you need to log in
Use HSV for the color, change the hue from 0 to 360 (or whatever color range you want), up/down 1 at a time. After each change, convert HSV to RGB and send to tape.
There is a simple algorithm, you can write it yourself, without libraries.
That's right they said - here HSV is best suited. A long time ago I did functions for Pascal, in that branch in C they posted something similar. Look, it will be useful for implementation.
Functions for converting RGB >> HSV
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question