Back to Johnny Five

LED - Rainbow BlinkM

docs/led-rgb-BLINKM.md

2.1.01.1 KB
Original Source
<!--remove-start-->

LED - Rainbow BlinkM

<!--remove-end-->

Demonstrates use of a BlinkM by cycling through rainbow colors.

Tessel - BlinkM Basick

emonstrates use of a BlinkM, with a Tessel 2, by cycling through rainbow colors.

 

Run this example from the command line with:

bash
node eg/led-rgb-BLINKM.js
javascript
const { Board, Led } = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  // Initialize the RGB LED
  const rgb = new Led.RGB({
    controller: "BLINKM"
  });
  let index = 0;
  const rainbow = ["FF0000", "FF7F00", "FFFF00", "00FF00", "0000FF", "4B0082", "8F00FF"];

  board.loop(1000, () => {
    if (index + 1 === rainbow.length) {
      index = 0;
    }
    rgb.color(rainbow[index++]);
  });
});

 

<!--remove-start-->

License

Copyright (c) 2012-2014 Rick Waldron [email protected] Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.

<!--remove-end-->