Hi,
I was looking for some scripts or nodes to steering the non programmable RGB strip lights by using 3 GPIO Raspberry pins 17, 27, 23. I have searched some python codes with transitions effects but how about the node-red and make some effects such as fading from one color to another with combination of colors or breath effetcs with the same.
There are also many tutorials on node-red forum but with programmable leds WLED, some web scripts with pickup colors and so one.
I want to make it simple so when I push the button I need to get the seqence for specific time for example:
transition / fading color from red to green with intermediate colors. Sequence runtime for example 3 seconds.
Do I need to use function node or maybe other. Please help me with this case.
-
Are these RGB lights in addition to the relays?
These RGB lights are connected as follow:
There aren't any additional controllers, relays etc.
GPIO pins 17, 27, 23 -
Is it a single light controlled by the pi?
It is the simple analog (non programmable) RGB strip 12V -
What type of light?
RGB strip 12V -
How are they connected?
as diragram above -
What three nodes are you talking about?
following nodes:
GPIO 17 - RED (red light rgb strip, GPIO number 17)
GPIO 27 - BLUE (blue light rgb strip, GPIO number 27)
GPIO 23 - GREEN (green light rgb strip, GPIO number 23)
The nodes which can do some fading effect (transition from one color to another):
- send the "1" message to each color node "R"; "G"; "B"
- set time for example 3 seconds - time of sequence working
- make some effect for example smooth change color from one to another with the colors between.
I found something in python more or less what to achive but there are all colors and I want for example step from red light to green light (with some colors between red and green).
I read that I can run node exec with run python script and to run terminal command sudo pigpiod but is it something simple?
The python code
Is there someone who this topic is related?
There are likely some nodes or flows that will do what you want, but it will involve some searching to find those. But your design is going to want a small change. Because you're not controlling a driver chip to run the lights and instead of using the Pi's GPIO to control a set of transistors, you're going to want to use the Pi's PWM outputs to control stuff like fade in and out. This will also do the breathing effects.
Then instead of looking for nodes to turn them on or off at high speed, look for nodes that can set the PWM parameters of the Pi pins themselves, which should be a simple matter of setting frequency and duty cycle. You'll also want to move from pins 17, 23 and 27 to some of pins 12, 13, 18 or 19. Those are PWM capable pins and will have the functionality built-in to the logic for those pins to do what you're wanting to do.
Thank you for your answer and I move my cables to pins which you mentioned. I will also start searching for the right nodes. I will return with some code
I think I know how to force the analog simply three nodes RGB lights to fade or change colors but I will need your guidance with it. I don't know javascript language to write this into function node.
I change the GPIO pins to following numbers 12 (red light), 13 (green light), 19 (blue light). I set those three nodes as PWM in node-red. It works quite well when I inject node for example number 50 or 10 the lights are darker so I started searching in javascript language and I find function called setIntervals.
The PWM for RGB starts from 0 low light to 100 full brightness light.
I think to start injection node with 1 number to send.
Then in between to put the function node to send the interval counter from 1 to 100 for example (I copy it from W3 school site)
<!DOCTYPE html>
<html>
<body>
<h1>The Window Object</h1>
<h2>The setInterval() and clearInterval() Methods</h2>
<p id="demo1"></p>
<p id="demo2" style="color:red;"></p>
<script>
setInterval(function() {myFunc("10", "20", "30" )}, 2000);
function myFunc(p1, p2) {
document.getElementById("demo1").innerHTML += "10", "20";
document.getElementById("demo2").innerHTML = "Parameters: " + p1 + " " + p2;
}
</script>
</body>
</html>
For the fade effect it will be function with one output to for example red light node
For the smooth effect it will be function with two outputs with two separate intervals one count from 1 to 100 to red light node and second count from 100 to 1 to green light node
Without having your exact setup, it's hard to verify. But I think you're on the right track. Let's say that you want to ramp a color from 0 to 100 over the span of three seconds. That means you're going to change values every 30ms in steps of 1. You could do it every 300ms in steps of 10, but you might notice the gradients. So for the function, you're going to want something like this (not the actual code):
setInterval(function() {//pull current PWM duty cycle and set the PWM cycle += 1;}, 30);
You're going to want to access the previous duty cycle value, which means you're going to need to find the function to get the current duty cycle, if one exists. It seems like you've already done a lot of research in this area to get to the point you're at. But you're really close to where you want to be. Let me know where you get stuck next, if at all, and I'll see what I can do to help.
Thanks for support and I will start to do something with this code in this week
I want to upload some of my early work about the RGB analog strip light effects. It is not ideal but there are some basics to future work
and the code:
[{"id":"827e38722d9198a7","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"0c7a2c86d9e65d59","type":"rpi-gpio out","z":"827e38722d9198a7","name":"RED Light PWM - GPIO 12","pin":"12","set":"","level":"0","freq":"","out":"pwm","bcm":true,"x":1820,"y":440,"wires":[]},{"id":"a004eadb6a3de1cf","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":930,"y":440,"wires":[["0c7a2c86d9e65d59"]]},{"id":"456930e851778319","type":"rpi-gpio in","z":"827e38722d9198a7","name":"Green Button GPIO 4 - ON","pin":"4","intype":"tri","debounce":"25","read":false,"bcm":true,"x":170,"y":440,"wires":[["ac9699643b0e9893","26281b624f21fc5a","7a9062779d1d0e9c","adb5b2e15fc60a43"]]},{"id":"ac9699643b0e9893","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":440,"wires":[["a004eadb6a3de1cf"]]},{"id":"26281b624f21fc5a","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":500,"wires":[["1c2b4334c177cc74"]]},{"id":"1c2b4334c177cc74","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":930,"y":500,"wires":[["871c92b5e17efb78"]]},{"id":"871c92b5e17efb78","type":"rpi-gpio out","z":"827e38722d9198a7","name":"Green Light PWM - GPIO 13","pin":"13","set":"","level":"0","freq":"","out":"pwm","bcm":true,"x":1820,"y":500,"wires":[]},{"id":"7a9062779d1d0e9c","type":"change","z":"827e38722d9198a7","name":"Switch to 15","rules":[{"t":"set","p":"payload","pt":"msg","to":"15","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":560,"wires":[["91c453d6de36a16f"]]},{"id":"91c453d6de36a16f","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":950,"y":560,"wires":[["27a9753cc1b918aa"]]},{"id":"27a9753cc1b918aa","type":"rpi-gpio out","z":"827e38722d9198a7","name":"Blue Light PWM - GPIO 19","pin":"19","set":"","level":"0","freq":"","out":"pwm","bcm":true,"x":1820,"y":560,"wires":[]},{"id":"adb5b2e15fc60a43","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"8","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":340,"y":640,"wires":[["729f0e1f6ab63ca4","67ba036475ad2399","05c11bc702f0bc45","2f53c1c0450a3ab2"]]},{"id":"729f0e1f6ab63ca4","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":640,"wires":[["a004eadb6a3de1cf"]]},{"id":"67ba036475ad2399","type":"change","z":"827e38722d9198a7","name":"Switch to 10","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":700,"wires":[["1c2b4334c177cc74"]]},{"id":"05c11bc702f0bc45","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":760,"wires":[["91c453d6de36a16f"]]},{"id":"2f53c1c0450a3ab2","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"8","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":340,"y":840,"wires":[["ed90c6da9d9d24bc","8b079f66c50b5dbd","2e6a0220b8ee34fd"]]},{"id":"ed90c6da9d9d24bc","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":840,"wires":[["a004eadb6a3de1cf"]]},{"id":"8b079f66c50b5dbd","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":900,"wires":[["1c2b4334c177cc74"]]},{"id":"2e6a0220b8ee34fd","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":960,"wires":[["91c453d6de36a16f"]]},{"id":"159d8cc934d1a4da","type":"comment","z":"827e38722d9198a7","name":"orange color","info":"","x":150,"y":640,"wires":[]},{"id":"4bd1ca8f8509b123","type":"comment","z":"827e38722d9198a7","name":"white end color","info":"","x":160,"y":840,"wires":[]},{"id":"3ed3fc61d14d85ca","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":970,"y":1040,"wires":[["0c7a2c86d9e65d59"]]},{"id":"295ccf6004cca963","type":"rpi-gpio in","z":"827e38722d9198a7","name":"Blue Button GPIO 3 - ON","pin":"3","intype":"tri","debounce":"25","read":false,"bcm":true,"x":210,"y":1040,"wires":[["2634438367264180","db7d186d81889178","1422d2340cd3e44c","8e56026926de627c"]]},{"id":"2634438367264180","type":"change","z":"827e38722d9198a7","name":"Switch to 10","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":1040,"wires":[["3ed3fc61d14d85ca"]]},{"id":"db7d186d81889178","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":1100,"wires":[["9d01417af3bf5136"]]},{"id":"9d01417af3bf5136","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":970,"y":1100,"wires":[["871c92b5e17efb78"]]},{"id":"1422d2340cd3e44c","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1160,"wires":[["5145118ec6e78150"]]},{"id":"5145118ec6e78150","type":"easing","z":"827e38722d9198a7","name":"","easingType":"linear","outputType":"overTime","duration":"3000","interval":"20","numberOfValues":10,"x":990,"y":1160,"wires":[["27a9753cc1b918aa"]]},{"id":"8e56026926de627c","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"8","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":380,"y":1240,"wires":[["11a9cf640d33c3c5","67f0a89ab0c31684","da85ea8293c2d391","14639d56653488af"]]},{"id":"11a9cf640d33c3c5","type":"change","z":"827e38722d9198a7","name":"Switch to 60","rules":[{"t":"set","p":"payload","pt":"msg","to":"60","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1240,"wires":[["3ed3fc61d14d85ca"]]},{"id":"67f0a89ab0c31684","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1300,"wires":[["9d01417af3bf5136"]]},{"id":"da85ea8293c2d391","type":"change","z":"827e38722d9198a7","name":"Switch to 10","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1360,"wires":[["5145118ec6e78150"]]},{"id":"cb0c5851e1053524","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":400,"y":1960,"wires":[["5c1dfd52811226ad","98962d4b6f609bb2","59f7846408b5233f"]]},{"id":"5c1dfd52811226ad","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1960,"wires":[["3ed3fc61d14d85ca"]]},{"id":"98962d4b6f609bb2","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2020,"wires":[["9d01417af3bf5136"]]},{"id":"59f7846408b5233f","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2080,"wires":[["5145118ec6e78150"]]},{"id":"8616639bb6f71519","type":"comment","z":"827e38722d9198a7","name":"violet color","info":"","x":180,"y":1240,"wires":[]},{"id":"a1bf589f6c5f7560","type":"comment","z":"827e38722d9198a7","name":"white end color","info":"","x":200,"y":1960,"wires":[]},{"id":"14639d56653488af","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":380,"y":1440,"wires":[["8a0a599be576e1d6","560b4c4b7f1cf1cd"]]},{"id":"67bffa821209026d","type":"comment","z":"827e38722d9198a7","name":"white end color","info":"","x":200,"y":1440,"wires":[]},{"id":"8a0a599be576e1d6","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1520,"wires":[["aa6a2da87237edee","d6c989c36c2eba59"]]},{"id":"aa6a2da87237edee","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1580,"wires":[["85ca4a5c21027c78","a8501d909d5b5773"]]},{"id":"85ca4a5c21027c78","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1640,"wires":[["d46c97565068ea51","21412a8ec85b4ddb"]]},{"id":"560b4c4b7f1cf1cd","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1440,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"d6c989c36c2eba59","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1520,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"a8501d909d5b5773","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1580,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"d46c97565068ea51","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1640,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"2604f0138188a02d","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1760,"wires":[["8a9ad136db43a55b","cae76f2abae3835a"]]},{"id":"8a9ad136db43a55b","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1820,"wires":[["a43ca967ddfe5377","cb0c5851e1053524"]]},{"id":"5738cddc0cdf6a43","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1700,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"cae76f2abae3835a","type":"change","z":"827e38722d9198a7","name":"Switch to 100","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1760,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"a43ca967ddfe5377","type":"change","z":"827e38722d9198a7","name":"Switch to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1820,"wires":[["0c7a2c86d9e65d59","871c92b5e17efb78","27a9753cc1b918aa"]]},{"id":"21412a8ec85b4ddb","type":"delay","z":"827e38722d9198a7","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":1700,"wires":[["2604f0138188a02d","5738cddc0cdf6a43"]]},{"id":"87e1495c1f06be88","type":"comment","z":"827e38722d9198a7","name":"TROPIKALNY DESZCZ","info":"","x":160,"y":380,"wires":[]}]
I have some problems with the stability of Blue button works because there are some artefacts between color changes.
If someone could see my code and tell me if there have to whether new changes are needed
Can you describe in a little more detail what you're seeing with the color changes? Artefacts can mean a number of things and it's hard to nail down an exact cause without knowing the effect it's causing.
I am not quite sure if I am correctly using only one pair of three nodes with PWM gpio colors.
When I hit the green button (first on the top) the sequence is running correctly but when I hit blue button the light start flickering with different colors mixing with right colors and I see it on three PWM colors nodes where at the bottom there are dynamic changes values from 0 to 100 and from 100 to 0. It looks like haotic but I see also that sequence is running step bu step. Maybe I have to resing the effect with quick white light change in second sequence but the flickering starts at the beginnings and running through all sequence
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.