Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
/* Mark Kriegsman's DemoReel 100 modified for APA104 RGB+W LEDs. This is the first humble attempt to use RGBW LEDs with FastLED. APA104 are 'improved' WS2812B, so this LED_TYPE can be chosen as well. The strip is set up with alternating Color and White LEDs. http://www.szledcolor.com.img.800cdn.com/upload/2015423162708_1.jpg To make things easier the White LEDs have also an 3 x 8 bit internal register and behave like normal color APA104, just with the difference that there are 768 brightness steps for the white LED. In order to address following them arrays were defined CRGB leds_Color[NUM_LEDS]; CRGB leds_White[NUM_LEDS]; To fill them with the right odd and even numbers Daniel Garcia contibuted this formula to allow the special FastLED functions. for(int i = 0; i < (NUM_LEDS/2); i++) { leds[i*2] = leds_Color[i]; leds[(i*2)+1] = leds_White[i]; } The function is executed in beginning of the loop. For optional plain access the arrays can be defined as uint8_t Array_Color[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142}; uint8_t Array_White[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143}; For longer strips you find at the bottom of the sketch even and odd numbers from 0 .. 1000 Gyro Gearloose June 2016 */ #include "FastLED.h" FASTLED_USING_NAMESPACE #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000) #warning "Requires FastLED 3.1 or later; check github for latest code." #endif #define DATA_PIN 12 //#define CLK_PIN 4 //#define LED_TYPE APA104 #define LED_TYPE WS2812B #define COLOR_ORDER GRB #define NUM_LEDS 144 CRGB leds[NUM_LEDS]; CRGB leds_Color[NUM_LEDS]; CRGB leds_White[NUM_LEDS]; uint8_t Array_Color[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142}; uint8_t Array_White[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143}; #define BRIGHTNESS 96 #define FRAMES_PER_SECOND 120 void setup() { delay(3000); // 3 second delay for recovery // tell FastLED about the LED strip configuration FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // set master brightness control FastLED.setBrightness(BRIGHTNESS); //for(int i = 0; i < (NUM_LEDS/2); i++) { leds[i*2] = leds_Color[i]; leds[(i*2)+1] = leds_White[i]; } Serial.begin(9600); } // List of patterns to cycle through. Each is defined as a separate function below. typedef void (*SimplePatternList[])(); SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, /*juggle,*/ bpm }; uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current uint8_t gHue = 0; // rotating "base color" used by many of the patterns void loop() { for(int i = 0; i < (NUM_LEDS/2); i++) { leds[i*2] = leds_Color[i]; leds[(i*2)+1] = leds_White[i]; } // Call the current pattern function once, updating the 'leds' array gPatterns[gCurrentPatternNumber](); // send the 'leds' array out to the actual LED strip FastLED.show(); // insert a delay to keep the framerate modest FastLED.delay(1000/FRAMES_PER_SECOND); // do some periodic updates EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically } #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) void nextPattern() { // add one to the current pattern number, and wrap around at the end gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); } void rainbow() { // FastLED's built-in rainbow generator //for(int i = 0; i < (NUM_LEDS/2); i++) { leds[i*2] = leds_Color[i]; /*leds[(i*2)+1] = leds_White[i];*/ } fill_rainbow( leds_Color, NUM_LEDS, gHue, 7); } void rainbowWithGlitter() { // built-in FastLED rainbow, plus some random sparkly glitter rainbow(); addGlitter(80); } void addGlitter( fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { leds_Color[ random16(NUM_LEDS) ] += CRGB::White; // leds_White[ random16(NUM_LEDS) ] += CRGB::White; // fadeToBlackBy( leds_White, NUM_LEDS, 10); } } void confetti() { // random colored speckles that blink in and fade smoothly fadeToBlackBy( leds_Color, NUM_LEDS, 10); int pos = random16(NUM_LEDS); leds_Color[pos] += CHSV( gHue + random8(64), 200, 255); } void sinelon() { // a colored dot sweeping back and forth, with fading trails fadeToBlackBy( leds_Color, NUM_LEDS/2, 20); int pos = beatsin16(13,0,NUM_LEDS/2); leds_Color[pos] += CHSV( gHue, 255, 192); } void bpm() { // colored stripes pulsing at a defined Beats-Per-Minute (BPM) uint8_t BeatsPerMinute = 62; CRGBPalette16 palette = PartyColors_p; uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); for( int i = 0; i < NUM_LEDS/2; i++) { //9948 leds_Color[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); } } void juggle() { //looks strange // eight colored dots, weaving in and out of sync with each other fadeToBlackBy( leds, NUM_LEDS, 20); byte dothue = 0; for( int i = 0; i < 8; i++) { leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255); dothue += 32; } } /* // even numbers 0..1000 2,4,6,8,10,12,14,16,18, 20,22,24,26,28,30,32,34,36, 38,40,42,44,46,48,50,52,54, 56,58,60,62,64,66,68,70,72, 74,76,78,80,82,84,86,88,90, 92,94,96,98,100,102,104,106,108, 110,112,114,116,118,120,122,124,126, 128,130,132,134,136,138,140,142,144, 146,148,150,152,154,156,158,160,162, 164,166,168,170,172,174,176,178,180, 182,184,186,188,190,192,194,196,198, 200,202,204,206,208,210,212,214,216, 218,220,222,224,226,228,230,232,234, 236,238,240,242,244,246,248,250,252, 254,256,258,260,262,264,266,268,270, 272,274,276,278,280,282,284,286,288, 290,292,294,296,298,300,302,304,306, 308,310,312,314,316,318,320,322,324, 326,328,330,332,334,336,338,340,342, 344,346,348,350,352,354,356,358,360, 362,364,366,368,370,372,374,376,378, 380,382,384,386,388,390,392,394,396, 398,400,402,404,406,408,410,412,414, 416,418,420,422,424,426,428,430,432, 434,436,438,440,442,444,446,448,450, 452,454,456,458,460,462,464,466,468, 470,472,474,476,478,480,482,484,486, 488,490,492,494,496,498,500,502,504, 506,508,510,512,514,516,518,520,522, 524,526,528,530,532,534,536,538,540, 542,544,546,548,550,552,554,556,558, 560,562,564,566,568,570,572,574,576, 578,580,582,584,586,588,590,592,594, 596,598,600,602,604,606,608,610,612, 614,616,618,620,622,624,626,628,630, 632,634,636,638,640,642,644,646,648, 650,652,654,656,658,660,662,664,666, 668,670,672,674,676,678,680,682,684, 686,688,690,692,694,696,698,700,702, 704,706,708,710,712,714,716,718,720, 722,724,726,728,730,732,734,736,738, 740,742,744,746,748,750,752,754,756, 758,760,762,764,766,768,770,772,774, 776,778,780,782,784,786,788,790,792, 794,796,798,800,802,804,806,808,810, 812,814,816,818,820,822,824,826,828, 830,832,834,836,838,840,842,844,846, 848,850,852,854,856,858,860,862,864, 866,868,870,872,874,876,878,880,882, 884,886,888,890,892,894,896,898,900, 902,904,906,908,910,912,914,916,918, 920,922,924,926,928,930,932,934,936, 938,940,942,944,946,948,950,952,954, 956,958,960,962,964,966,968,970,972, 974,976,978,980,982,984,986,988,990, 992,994,996,998,1000 // odd numbers 0..1000 1,3,5,7,9,11,13,15,17,19, 21,23,25,27,29,31,33,35,37, 39,41,43,45,47,49,51,53,55, 57,59,61,63,65,67,69,71,73, 75,77,79,81,83,85,87,89,91, 93,95,97,99,101,103,105,107,109, 111,113,115,117,119,121,123,125,127, 129,131,133,135,137,139,141,143, 145, 147,149,151,153,155,157,159,161,163, 165,167,169,171,173,175,177,179,181, 183,185,187,189,191,193,195,197,199, 201,203,205,207,209,211,213,215,217, 219,221,223,225,227,229,231,233,235, 237,239,241,243,245,247,249,251,253, 255,257,259,261,263,265,267,269,271, 273,275,277,279,281,283,285,287, 289, 291,293,295,297,299,301,303,305,307, 309,311,313,315,317,319,321,323,325, 327,329,331,333,335,337,339,341,343, 345,347,349,351,353,355,357,359,361, 363,365,367,369,371,373,375,377,379, 381,383,385,387,389,391,393,395,397, 399,401,403,405,407,409,411,413,415, 417,419,421,423,425,427,429,431,433, 435,437,439,441,443,445,447,449,451, 453,455,457,459,461,463,465,467,469, 471,473,475,477,479,481,483,485,487, 489,491,493,495,497,499,501,503,505, 507,509,511,513,515,517,519,521,523, 525,527,529,531,533,535,537,539,541, 543,545,547,549,551,553,555,557,559, 561,563,565,567,569,571,573,575,577, 579,581,583,585,587,589,591,593,595, 597,599,601,603,605,607,609,611,613, 615,617,619,621,623,625,627,629,631, 633,635,637,639,641,643,645,647,649, 651,653,655,657,659,661,663,665,667, 669,671,673,675,677,679,681,683,685, 687,689,691,693,695,697,699,701,703, 705,707,709,711,713,715,717,719,721, 723,725,727,729,731,733,735,737,739, 741,743,745,747,749,751,753,755,757, 759,761,763,765,767,769,771,773,775, 777,779,781,783,785,787,789,791,793, 795,797,799,801,803,805,807,809,811, 813,815,817,819,821,823,825,827,829, 831,833,835,837,839,841,843,845,847, 849,851,853,855,857,859,861,863,865, 867,869,871,873,875,877,879,881,883, 885,887,889,891,893,895,897,899,901, 903,905,907,909,911,913,915,917,919, 921,923,925,927,929,931,933,935,937, 939,941,943,945,947,949,951,953,955, 957,959,961,963,965,967,969,971,973, 975,977,979,981,983,985,987,989,991, 993,995,997,999 */
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Improved Sed.cs
C# | 5 hours ago | 11.77 KB
Horrible formatting made better
C# | 5 hours ago | 0.37 KB
How to correctly instantiate an HttpClient
C# | 5 hours ago | 0.72 KB
VLF: VLF Notes: VMware ESXi for VSI/VMS hobby...
20 hours ago | 14.59 KB
best journal
21 hours ago | 0.05 KB
evdev 2nd seat v4.04
Python | 1 day ago | 21.13 KB
LearnDash - Aelia Currency Switcher integrati...
PHP | 1 day ago | 5.25 KB
bcachefs read error
1 day ago | 1.11 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!