Software Setup
If this is your first time using Trinket, it's a great idea to check out the Introduction to Trinket guide first.
Once you've got your Trinket up and running with Arduino, you'll need to install the FastLED library.
Libraries? Why? What's a Library?
In a nutshell, Arduino libraries have a lot of pre-written functions that make your neopixels easy to command. You can do fancy stuff without being a code guru. Yay Libraries!
FastLED is a fast, efficient, easy-to-use Arduino library for programming addressable LED strips and pixels. It has a lot of features to get your animations up and running fast -- and it has a lot of code samples available if you're just learning to code.
Open up the Arduino library manager:
Search for the FastLED library and install it
We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Once your curiosity is satiated and your library is installed, copy and paste the code into your Arduino window.
Go to your Tools menu and select "Adafruit Trinket 16MHZ" from the list of boards. Plug your Trinket into your computer via the onboard USB port. Press the "reset" button on your Trinket and wait for the blinky red light, then click the upload button in Arduino.
#include <FastLED.h> #define NEO_PIN 4 #define NUM_LEDS 9 //set number of LEDs in your strip #define SPEED 10 //change motion speed here #define STEPS 10 #define BRIGHTNESS 90 //change brightness here #define COLOR_ORDER GRB CRGB leds[NUM_LEDS]; CRGBPalette16 currentPalette; TBlendType currentBlending; void setup() { delay( 1000 ); // power-up safety delay FastLED.addLeds<WS2812B, NEO_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentBlending = LINEARBLEND; currentPalette = OceanColors_p; // Un-comment the color scheme you want //currentPalette = RainbowColors_p; //currentPalette = HeatColors_p; //currentPalette = PartyColors_p; //currentPalette = CloudColors_p; //currentPalette = RainbowStripeColors_p; //currentPalette = ForestColors_p; } void loop() { static uint8_t startIndex = 0; startIndex = startIndex + 1; /* motion speed */ FillLEDsFromPaletteColors( startIndex); FastLED.show(); FastLED.delay(1000 / SPEED); } //this bit is in every palette mode, needs to be in there just once void FillLEDsFromPaletteColors( uint8_t colorIndex) { uint8_t brightness = BRIGHTNESS; for( int i = 0; i < NUM_LEDS; i++) { leds[i] = ColorFromPalette( currentPalette, colorIndex + sin8(i*16), brightness, currentBlending); colorIndex += STEPS; } }
If you encounter trouble…
Any time you hit a roadblock with a NeoPixel project, we’ll usually ask that you start with the “strandtest” example from our own Adafruit_NeoPixel library. This helps us narrow down whether it’s a hardware or software issue.
Open up the Arduino library manager:
Search for the Adafruit Neopixel library and install it
You’ll find the strandtest example under File→Sketchbook→Libraries→Adafruit_NeoPixel→strandtest
If strandtest fails to run, this suggests a hardware issue…for example, connecting to the wrong Trinket pin.
If you’re new to Arduino programming and LEDs, we usually suggest starting with the Adafruit_NeoPixel library…it’s pretty basic, the strip declaration is more conventional, and we can stay on top of keeping it compatible with our own products and the most mainstream Arduino boards.
As FastLED is a more “bleeding edge” third-party library, we can’t always guarantee compatibility across versions or with specific boards. You can find help through their community on Google+. This is potent stuff, written by people with a deep appreciation for LED art, and we wanted to showcase it.
Page last edited March 08, 2024
Text editor powered by tinymce.