FastLED 3.10.8
Loading...
Searching...
No Matches
AnalogOutput.ino
Go to the documentation of this file.
1// @filter: (board is not atmega8*)
5
6#include <Arduino.h>
7#include <FastLED.h>
8
9
10
11// Example showing how to use FastLED color functions
12// even when you're NOT using a "pixel-addressible" smart LED strip.
13//
14// This example is designed to control an "analog" RGB LED strip
15// (or a single RGB LED) being driven by Arduino PWM output pins.
16// FastLED's ANALOG_RGB controller applies brightness, color correction, and
17// color temperature before writing PWM duty cycles to the three output pins.
18//
19// In this example, the RGB values are output on three separate
20// 'analog' PWM pins, one for red, one for green, and one for blue.
21
22#define REDPIN 5
23#define GREENPIN 6
24#define BLUEPIN 3
25
27
28// Set the single analog RGB output color and update its PWM pins.
29void showAnalogRGB( const CRGB& rgb)
30{
31 leds[0] = rgb;
32 FastLED.show();
33}
34
35
36
37// colorBars: flashes Red, then Green, then Blue, then Black.
38// Helpful for diagnosing if you've mis-wired which is which.
40{
41 showAnalogRGB( CRGB::Red ); delay(500);
42 showAnalogRGB( CRGB::Green ); delay(500);
43 showAnalogRGB( CRGB::Blue ); delay(500);
44 showAnalogRGB( CRGB::Black ); delay(500);
45}
46
47void loop()
48{
49 static uint8_t hue;
50 hue = hue + 1;
51 // Use FastLED automatic HSV->RGB conversion
52 showAnalogRGB( CHSV( hue, 255, 255) );
53
54 delay(20);
55}
56
57
58void setup() {
60 .setCorrection(TypicalLEDStrip)
61 .setTemperature(DirectSunlight);
62 FastLED.setBrightness(192);
63
64 // Flash the "hello" color sequence: R, G, B, black.
65 colorBars();
66}
CRGB leds[1]
void colorBars()
void showAnalogRGB(const CRGB &rgb)
void setup()
#define REDPIN
#define GREENPIN
#define BLUEPIN
void loop()
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint8_t hue
Definition advanced.h:94
FastLED chipset-style wrapper for three-pin PWM RGB output.
Definition analog.h:56
@ DirectSunlight
6000 Kelvin
Definition color.h:58
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
fl::hsv8 CHSV
Definition chsv.h:11
fl::CRGB CRGB
Definition crgb.h:25
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:565
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:629
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:519
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:517