Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//*************************************************************** // Code example for Post-Master Sodium // https://plus.google.com/112460818250824432487/posts/4MiomMJAcpF // // This is a modified version of Erin St Blaine's animated glow // scarf code from: // https://learn.adafruit.com/animated-neopixel-gemma-glow-fur-scarf/the-code // // // Marc Miller, May 2017 //*************************************************************** #include <FastLED.h> // Number of hoops, and number of leds in each hoop #define NUM_HOOPS 4 // number of hoops in the dress #define NUM_HOOP1 8 // how many LEDs in 1st hoop #define NUM_HOOP2 8 // how many LEDs in 2nd hoop #define NUM_HOOP3 8 // how many LEDs in 3rd hoop #define NUM_HOOP4 8 // how many LEDs in 4th hoop // Total LEDs in the whole dress, which is the sum of the leds from all hoops #define NUM_LEDS NUM_HOOP1 + NUM_HOOP2 + NUM_HOOP3 + NUM_HOOP4 CRGB leds[NUM_LEDS]; CRGB leds_temp[NUM_HOOPS]; // Temp array of length NUM_HOOPS for blending colors #define DATA_PIN 11 #define CLOCK_PIN 13 #define COLOR_ORDER GRB // Try mixing up the letters (RGB, GBR, BRG, etc) for a whole new world of color combinations #define BRIGHTNESS 200 // 0-255, higher number is brighter. #define SATURATION 255 // 0-255, 0 is pure white, 255 is fully saturated color #define SPEED 10 // How fast the colors move. Higher numbers = faster motion #define STEPS 10 // How agressive the color gradient is. Lower is smoother transition. #define BUTTON_PIN 4 // button is connected to pin 2 and GND //--------------------------------------------------------------- //FastLED comes with several palettes pre-programmed. I like purple a LOT, and so I added a custom purple palette. const TProgmemPalette16 PurpleColors_p PROGMEM = { CRGB::Purple, CRGB::Purple, CRGB::MidnightBlue, CRGB::MidnightBlue, CRGB::Purple, CRGB::Purple, CRGB::BlueViolet, CRGB::BlueViolet, CRGB::DarkTurquoise, CRGB::DarkTurquoise, CRGB::DarkBlue, CRGB::DarkBlue, CRGB::Purple, CRGB::Purple, CRGB::BlueViolet, CRGB::BlueViolet }; //--------------------------------------------------------------- CRGBPalette16 currentPalette; CRGBPalette16 targetPalette( PurpleColors_p ); TBlendType currentBlending; int ledMode = 4; // Starting palette unsigned long keyPrevMillis = 0; const unsigned long keySampleIntervalMs = 25; byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms byte longKeyPressCount = 0; byte prevKeyState = HIGH; // button is active low //--------------------------------------------------------------- void setup() { Serial.begin(115200); delay(3000); // 3 second delay FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentBlending =LINEARBLEND; pinMode(BUTTON_PIN, INPUT_PULLUP); // Check sum of hoop pixels add up to the total number of pixels in dress Serial.print("Total number of pixels (ie. NUM_LEDS): "); Serial.println(NUM_LEDS); } //--------------------------------------------------------------- void loop() { byte currKeyState = digitalRead(BUTTON_PIN); if ((prevKeyState == LOW) && (currKeyState == HIGH)) { shortKeyPress(); } prevKeyState = currKeyState; static uint8_t startIndex = 0; startIndex = startIndex + 1; /* motion speed */ switch (ledMode) { case 0: currentPalette = HeatColors_p; //Red & Yellow, Fire Colors break; case 1: currentPalette = ForestColors_p; //Foresty greens and yellows break; case 2: currentPalette = OceanColors_p; //Oceans are pretty and filled with mermaids break; case 3: currentPalette = PurpleColors_p; //My custom palette from above break; case 4: currentPalette = RainbowColors_p; //All the colors! break; case 5: currentPalette = RainbowStripeColors_p; //Rainbow stripes break; case 6: currentPalette = PartyColors_p; //All the colors except the greens, which make people look a bit washed out break; } FillLEDsFromPaletteColors( startIndex); FillHoops(); FastLED.show(); FastLED.delay(1000 / SPEED); } //--------------------------------------------------------------- void FillLEDsFromPaletteColors( uint8_t colorIndex) { // **modified to use NUM_HOOPS and leds_temp** for( int i = 0; i < NUM_HOOPS; i++) { leds_temp[i] = ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending); colorIndex += STEPS; } } //--------------------------------------------------------------- void shortKeyPress() { ledMode++; if (ledMode > 6) { ledMode=0; } } //--------------------------------------------------------------- void FillHoops() { //Copy the colors from leds_temp to leds, filling the number of pixels in each hoop // start position, number to fill, fill color fill_solid(leds, NUM_HOOP1, leds_temp[0]); fill_solid(leds+NUM_HOOP1, NUM_HOOP2, leds_temp[1]); fill_solid(leds+NUM_HOOP1 + NUM_HOOP2, NUM_HOOP3, leds_temp[2]); fill_solid(leds+NUM_HOOP1 + NUM_HOOP2 + NUM_HOOP3, NUM_HOOP4, leds_temp[3]); // If there are more of less hoops this will need to be adjusted as needed. // Uncomment the below when testing to visualize the leds_temp R,G,B values //EVERY_N_SECONDS(1) { // Serial.print("leds_temp[0]: "); Serial.print(leds_temp[0].r); Serial.print("\t"); // Serial.print(leds_temp[0].g); Serial.print("\t"); Serial.println(leds_temp[0].b); // Serial.print("leds_temp[1]: "); Serial.print(leds_temp[1].r); Serial.print("\t"); // Serial.print(leds_temp[1].g); Serial.print("\t"); Serial.println(leds_temp[1].b); // Serial.print("leds_temp[2]: "); Serial.print(leds_temp[2].r); Serial.print("\t"); // Serial.print(leds_temp[2].g); Serial.print("\t"); Serial.println(leds_temp[2].b); // Serial.print("leds_temp[3]: "); Serial.print(leds_temp[3].r); Serial.print("\t"); // Serial.print(leds_temp[3].g); Serial.print("\t"); Serial.println(leds_temp[3].b); // Serial.println(" "); //} }
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
Documents
9 min ago | 0.43 KB
Crypto admin access
9 min ago | 0.43 KB
+12,000$ in 2 days
CSS | 10 min ago | 0.72 KB
Free Crypto Method
CSS | 11 min ago | 0.72 KB
Altur Song Lyrics
26 min ago | 13.27 KB
CC:T GPS Beacon
11 hours ago | 0.49 KB
R4 Moon SPI Screen With Wifi
Arduino | 13 hours ago | 13.55 KB
Art school
1 day ago | 1.06 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!