Go Down

Topic: A library to control a rgb lamp without using delay (Read 365 times) previous topic - next topic

Stilren

Hi! I wrote a library for controlling a RGB lamp that does not use delay functionality.

https://github.com/stilren/RGBLamp

Example for having a led blink (or rather pulse) continuously:

Code: [Select]
#include "RGBLamp.h"

RGBLamp myLamp;
int redPin = 3;
int greenPin = 5;
int bluePin = 6;
int mode = COMMON_ANODE;

void setup() {
  myLamp.begin(mode, redPin, greenPin, bluePin); //Make sure pins are PWM-pins if you want to use fadeTo or blink fucntions.
  myLamp.blink(Color::Cyan);
}

void loop() {
  myLamp.update(); //Run continuously
}


I needed it for a project im working on and couldnt find a library that suited me. After finishing it up i decided to put some final touches on it and upload it to github under MIT license. I was using it together with a Timer library to ensure the correct update rate but I also included a update-function in this lib. Besides just telling you guys that its out there I am also looking for feedback regarding the code!

Go Up