Coder Social home page Coder Social logo

micahstevens / ftrgbled Goto Github PK

View Code? Open in Web Editor NEW

This project forked from freetronics/ftrgbled

0.0 2.0 0.0 171 KB

Arduino library for Freetronics RGBLED module - WS2801 based RGB LED

Home Page: http://www.freetronics.com/rgbled

License: GNU Lesser General Public License v3.0

C++ 45.84% Arduino 54.16%

ftrgbled's Introduction

This is an Arduino library for the Freetronics RGBLED module, based on the WS2801 LED controller chip.

http://www.freetronics.com/products/rgb-led-module

RGBLED Module

Supported on Arduino 1.0.5 or newer, or Arduino 1.5.4 or newer.

Usage

The library ships with 3 examples which you can find under File -> Examples -> FTRGBLED. Adapting an example is the easiest way to get started.

Include library

At the very top of your sketch, include the library:

#include <FTRGBLED.h>

Declare RGBLEDChain

Near the top of the sketch but after the include line, declare a RGBLEDChain like this:

RGBLEDChain leds(NUM_LEDS, PIN_CKI, PIN_SDI);

NUM_LEDS is the number of LEDs in the chain.

PIN_CKI and PIN_SDI are the pin numbers for the CKI and SDI pins on the module.

Setup section - call begin

In the setup method, call begin() on the RGBLEDChain like this:

void setup() {
    leds.begin();
}

Set colours

To set individual colours, call setLED():

leds.setLED(0, LED_YELLOW);

The first parameter is the LED number (starting from zero.)

The second parameter is the LED colour.The library predefines some constants for colours - LED_WHITE, LED_BLACK, LED_RED, LED_GREEN, LED_YELLOW, LED_VIOLET.

You can also specify a colour as { Red, Green, Blue } values. Either like this:

leds.setLED(0, { 200, 100, 0 });

Or like this:

const FTLEDColour MY_COLOUR = { 200, 100, 0 };
leds.setLED(0, MY_COLOUR);

To set all the LEDs to the same colour, use the setLEDs() method:

leds.setLEDs(LED_GREEN);

Calling setLED and setLEDs doesn't change the colours of the LEDs though. To actually change the colours you have to call update():

leds.update();

This means you can set multiple LEDs to different colours, and then call update() once to save time.

Copyright & License

Copyright (C) 2013 Freetronics Pty Ltd. Released under the GNU Lesser General Public License V3 as described in the LICENSE file.

ftrgbled's People

Contributors

micahstevens avatar projectgus avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.