Reusing some RGB LED interior lighting modules

Posted on
  • A while ago I bought IR remote controlled RGB Lighting modules - see attached pics. They did great until I switched to white and then they froze on that color - and now it is time to do some destructive construction with these modules and celebrate something of the past: My very first Espruino 'project' - four plus (4+) years ago - was playing with the RGB LEDs of the Original Espruino board:

    Inspired by the great number of user input/output elements - BTN1 button and LEDs LED1, LED2, and LED3 - on the Espruino board right out-of-box, my first hands-on experience and fun was coding running led lights - red-green-blue-... - controlled by the BTN1 button:... ( ...start, stop, run faster and run slower)....

    The conversation was named Software Buttons - Many buttons from just one hardware button, because it was a next step of the light show as conceived as result of a conversation that had asked: What is LED1/A13? (addressing pins via variables). ...can LEDs be addressed by a variable? (By now, they an

    Today's project is less about plain on and off and running, but more about smooth, 'wavy' transition from color to color in in all of the spectrum - watch .mp4 clip below:

    3 Attachments

  • The transitions are achieved by modulation pwm - modifying duty cycle - from 0 to 1 and back using sine wave -and overlay this modulation with another sine wave - sine modulating the speed of the sine wave that modulates the pwm duty cycle. This is done for each color - R, G and B - with all individual and different wave lengths - frequencies - totally six (6). Initially I had only the pwm modulation on different modulation frequencies. But even though they were all different in frequency AND also prime numbers, pretty flat rhythm was felt. Thats why I overlaid the initial waves with a second wave. The difference it very noticeable and the light intensity and color change feels more what nature shows, for example, the ocean waves that crash coming ashore and pushing bubbly water up a sandy, slightly sloped beach: it is not just a 'come and go', but more like a come a bit, retreat a little bit, and then advance more, almost like the ascend over pre-peaks to the main peak when mountain hiking.

    The modules have an IR receiver, some attiny875 chip and a 1kx8 flash EEPROM for controlling 4 banks of RGB 2 x 3 LEDs. Since this control setup did not budge anymore, I removed these three components and connected wires to the Base/Gate of 'power' bipolar Transistor / FET and control latter with pins A1, A2 and A3 of a PICO. The RGB LED side of the modules is 12V driven with the RGB LEDs on the HIGH side and the bipolar Transistor / FET on the LOW side.

    And here is the code in a very - flat - implementation.

    // someTriColors.js
    // (c)20181101 allObjects
    // reusing ir colorable interior lights
    // sine modulated sine modulated pwm...
    var itpf =   2; // interval time pwm factor
    var itdf =   5; // interval time pwm delta factor
    var pi2  = Math.PI*2, rdd = pi2 / 90;
    var pr   =  A1, pg   =  A2, pb   =  A3; // pin for r, g and b
    var pwmr =   0, pwmg =   0, pwmb =   0; // pwm value of r, g and b
    var pwdr = rdd, pwdg = rdd, pwdb = rdd; // pwm delta (increment)
    var itpr =   7, itpg =  11, itpb =  17; // pwm interval time of r, g and b
    var iipr      , iipg      , iipb      ; // pwm interval id of r, g and b
    var pddr =   0, pddg =   0, pddb =   0; // pwm delta delta
    var itdr =  30, itdg =  37, itdb =  47; // pwm delta delta interval time
    var iidr      , iidg      , iidb      ; // pwm delta delta interval id of r, g and 
    function adpr() {
      pwmr = ((pwmr += pwdr) < pi2) ? pwmr : 0;
      analogWrite(pr,(1 + Math.sin(pwmr)) / 2);
    function adpg() {
      pwmg = ((pwmg += pwdg) < pi2) ? pwmg : 0;
      analogWrite(pg,(1 + Math.sin(pwmg)) / 2);
    function adpb() {
      pwmb = ((pwmb += pwdb) < pi2) ? pwmb : 0;
      analogWrite(pb,(1 + Math.sin(pwmb)) / 2);
    function addr() {
      pddr = ((pddr += rdd) < pi2) ? pddr : 0;
      pwdr = rdd * ((1 + Math.sin(pddr)) / 2);
    function addg() {
      pddg = ((pddg += rdd) < pi2) ? pddg : 0;
      pwdg = rdd * ((1 + Math.sin(pddg)) / 2);
    function addb() {
      pddb = ((pddb += rdd) < pi2) ? pddb : 0;
      pwdb = rdd * ((1 + Math.sin(pddb)) / 2);
    function goPWMs() {
      iipr = setInterval(adpr,itpr * itpf);
      iipg = setInterval(adpg,itpg * itpf);
      iipb = setInterval(adpb,itpb * itpf);  
    function goDeltas() {
      iidr = setInterval(addr,itdr * itdf);
      iidg = setInterval(addg,itdg * itdf);
      iidb = setInterval(addb,itdb * itdf);  
    function onInit() {

    Code is 'flat' because it is 3 (6) times the same: modifying / modulating something with a sine wave... with everything done for each individual color R, G, and B. 'flat' is faster in execution... even though speed is of no essence right now... When cranking up the cycles though, it could come to matter.

    Next - unrelated - exercise will be the checking out of the remote and the IR receiver... ;-)

  • Nice - so how did your wire up the Espruino? Is it powered from the light's power supply as well?

    There's actually­BtoRGB which might be some use colour cycling stuff. Not as fun though :)

  • Thanks for the hint. Making something really fun needs a bit more creativity than two layered sine modulations. Something similar I created in the past: a camp fires for stage prop - non-electronic: colored tissue papers stapled to a few split logs for flames over a fan and spot lamp - and electronc: a flickering fire for a nativity scene scene 1:10 using partially burned matches and a bunch of colored small LEDs, driven with some 13 stage binary counter and left-over NANDs driven by a free running multivibrator w/ NANDs. First as recent as this summer for a kids musical, latter 20+ years ago for my wife.

    Currently, it was supplied separately while still on the 'lab bench'. A 12V 1A switched power supply feeds the lights, Espruino PICO was still connected to the IDE. I know that I can drive PICO as well from the 12V. The module allows to be fed w/ 12V DC or AC, because it has a full way rectifier bridge (DB1) on it - zoom into the pic to see it. The 5V for mc, memory and IR receiver are created with a Zener (Z1) and 390R resistor (R13) and 'supported' by a capacitor (C1) - +5V on the left side, 0V/GND on the right side (on the lower module in the pic, back of the board). While the components were still on, I measured something like 4.89V across the Zener. Running for a while, stuff got a bit warm, especially the rectifier bridge, as I could feel. With components off, the 5V circuitry has no load anymore.

  • Check conversation about IR RC - Infrared Remote Control out. It covers how to use the -now not used anymore - Infrared Remote Control components as a control and input device for Espruino applications.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Reusing some RGB LED interior lighting modules

Posted by Avatar for allObjects @allObjects