1

I have this RGB 5050 LED trip. Im currently using this with an Arduino board and Johnny-Five platform because I need to use Javascript to control it. I want to make the LED blink on a certain frequency and this will increase slowly.

For a single color LED, they have this command:

led.fade(brightness, ms)

but this doesn't work for RGB LED (what is just stupid).

The only option that I've found is this:

function FadeIN(){
  led.intensity(i);
  i++; 

  if(i < 100){
    setTimeout( FadeIN, (Timer[y]/20));
  }                        
}

This is a loop function, I had to do in this way because you actually can't use setTimeout() inside a for or while loop. Im also using a similar function to Fade Out the LED.

The issue is: It works for a short period. But sometimes it literally skips a beep. Also, sometimes it just is so fast that the luminosity reduction (Fade Out) is just negligible, not even reaching "0" and starting to increase again.

Im sure that this isn't a hardware limitation (Arduino), because I've achieve what I want using Arduino Editor and C++.

At J5 website they have a lot of commands and examples only for single color LED, but nothing for RGB.

Can anyone help?

MWsan
  • 448
  • 1
  • 8
  • 20

1 Answers1

0

Note that the RGB LEDs need to be instantiated differently than the single color LEDs. They have more pins, after all! Here's an example:

var led = new five.Led.RGB([9, 10, 11]);

There is documentation for using RGB LEDs at https://github.com/rwaldron/johnny-five/wiki/led.rgb and http://johnny-five.io/api/led.rgb/. In fact, here is documentation on changing the RGB LEDs's intensity over time: http://johnny-five.io/examples/led-rgb-intensity/. From that document:

var temporal = require("temporal");
var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  // Initialize the RGB LED
  var led = new five.Led.RGB([6, 5, 3]);

  // Set to full intensity red
  console.log("100% red");
  led.color("#FF0000");

  temporal.queue([{
    // After 3 seconds, dim to 30% intensity
    wait: 3000,
    task: function() {
      console.log("30% red");
      led.intensity(30);
    }
  }, {
    // 3 secs then turn blue, still 30% intensity
    wait: 3000,
    task: function() {
      console.log("30% blue");
      led.color("#0000FF");
    }
  }, {
    // Another 3 seconds, go full intensity blue
    wait: 3000,
    task: function() {
      console.log("100% blue");
      led.intensity(100);
    }
  }, ]);
});
KatieK
  • 13,586
  • 17
  • 76
  • 90