Skip to content

Instantly share code, notes, and snippets.

@futureshocked
Created March 27, 2018 00:50
Show Gist options
  • Save futureshocked/510bd43f5fa3646e646f19407aa14d0b to your computer and use it in GitHub Desktop.
Save futureshocked/510bd43f5fa3646e646f19407aa14d0b to your computer and use it in GitHub Desktop.
A simplified version of the example sketch that comes with the RGBLED library
#include "RGBLED.hpp"
// Pin mapping for the first RGBLED object:
const byte redLed = 3;
const byte greenLed = 5;
const byte blueLed = 6;
// The RGBLED object defaults to common cathode configuration.
RGBLED rgbLed(redLed, greenLed, blueLed);
void setup() {
Serial.begin(250000);
Serial.println("RGBLED 'hello_world' example.");
rgbLed.brightness(PWM_MAX); // Sets the brightness.
}
void loop() {
// Turns ON the led.
rgbLed.on();
// Sets PWM for a color. Get these numbers from the Google Color chooser.
rgbLed.red(115); rgbLed.green(183); rgbLed.blue(150);
// The method 'RGBLED::show()' must be called to execute the changes.
rgbLed.show();
delay(1000); // Keep this color for 1 second
// Turns OFF the led. This must be done so that we can change the color
rgbLed.off();
// Turns ON the led.
rgbLed.on();
// Sets PWM for a color. Get these numbers from the Google Color chooser.
rgbLed.red(183); rgbLed.green(115); rgbLed.blue(146);
// The method 'RGBLED::show()' must be called to execute the changes.
rgbLed.show();
delay(1000);
// Turns OFF the led. This must be done so that we can change the color
rgbLed.off();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment