GithubHelp home page GithubHelp logo

myrthedpvn / rgbled Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wilmouths/rgbled

0.0 0.0 0.0 49 KB

An Arduino library to control RGB led

License: GNU General Public License v3.0

C++ 100.00%

rgbled's Introduction

RGBLed Arduino library

This library for Arduino allows you to control RGB led.

Installation

Installing Additional Arduino Libraries

Usage

  • Include library file header
#include <RGBLed.h>
  • Create an object, this object takes one parameter which corresponds to the analog pins are connected to on the Arduino.
RGBLed led(RED_PIN, GREEN_PIN, BLUE_PIN, RGBLed::COMMON_ANODE or RGBLed::COMMON_CATHODE);
  • Set color
led.setColor(RGBLed::RED);
// or
led.setColor(255, 0, 0);
  • Light off
led.off();
  • Set LED relative brightness level. (Note: brightness level defaults to 100.)
led.brightness(50); // 50% brightness
  • Set brightness and color at the same time ()
led.brightness(RGBLed::RED, 50); // 50% brightness
// or
led.brightness(255, 0, 0, 50); // 50% brightness
  • Flash
led.flash(RGBLed::RED, 100); // Interval 100ms
// or
led.flash(255, 0, 0, 100); // Interval 100ms

led.flash(RGBLed::RED, 250, 100); // Light on during 250ms and flash with interval (100ms)
// or
led.flash(255, 0, 0, 250, 100); // Light on during 250ms and flash with interval (100ms)
  • Fade In or Out
led.fadeOut(RGBLed::RED, 5, 100); // Fade out with 5 steps during 100ms
// or
led.fadeOut(255, 0, 0, 5, 100); // Fade out with 5 steps during 100ms

led.fadeIn(RGBLed::RED, 5, 100); // Fade in with 5 steps during 100ms
// or
led.fadeIn(255, 0, 0, 5, 100); // Fade in with 5 steps during 100ms
  • Cross Fade between two colors
// Usage: led.crossFade(rgbFrom[3], rgbTo[3], steps, duration)
led.crossFade(RGBLed::RED, RGBLed::GREEN, 5, 100);  // Fade from RED to GREEN in 5 steps during 100ms 
// or 
// Usage: led.crossFade(fromR, fromG, fromB, toR, toG, toB, steps, duration)
led.crossFade(255, 0, 0, 0, 255, 0, 5, 100);    // Fade from RED to GREEN in 5 steps during 100ms 

Colors

You can create your own colors or use the followings colors

  • RED
  • GREEN
  • BLUE
  • MAGENTA
  • CYAN
  • YELLOW
  • WHITE

How use colors ?

RGLed::RED

Contributors

Thank you to all our contributors!

rgbled's People

Contributors

wilmouths avatar hpreston avatar davidob avatar izhanghui avatar manghao avatar calania avatar per1234 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.