Demonstrates use of an RGB LED (common anode) with the PCA9685 controller by setting its color to red (#ff0000) and making it blink.

Breadboard for "LED - RGB (Common Anode) PCA9685"


Fritzing diagram: led-rgb-anode-PCA9685.fzz


Run this example from the command line with:

node eg/led-rgb-anode-PCA9685.js
var five = require("johnny-five");
var board = new five.Board();

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

  // Initialize the RGB LED
  var led = new five.Led.RGB({
    controller: "PCA9685",
    isAnode: true,
    pins: {
      red: 2,
      green: 1,
      blue: 0

  // RGB LED alternate constructor
  // This will normalize an array of pins in [r, g, b]
  // order to an object (like above) that's shaped like:
  // {
  //   red: r,
  //   green: g,
  //   blue: b
  // }
  // var led = new five.Led.RGB({
  //   pins: [2, 1, 0],
  //   isAnode: true,
  //   controller: "PCA9685"
  // });

  // Add led to REPL (optional)
    led: led

  // Turn it on and set the initial color




Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub