Using the NeoRGB Stemma with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_NeoPixel library and running the provided example code.
Wiring
Your wiring will differ depending on how many total amps will be used across all three RGB channels. Here is how you'll wire the breakout to an Adafruit Metro and a single RGB LED with less than 2A total used across all three RGB channels:
- Metro 5V to NeoRGB JST PH VIN (red wire)
- Metro GND to NeoRGB JST PH GND (black wire)
- Metro pin 6 to NeoRGB JST PH SIG (white wire)
- NeoRGB RED to RGB LED red anode (pink wire)
- NeoRGB GRN to RGB LED green anode (green wire)
- NeoRGB BLU to RGB LED blue anode (blue wire)
- NeoRGB GND to RGB LED cathode (black wire)
Here is how you'll wire the breakout to an Adafruit Metro and a 12V RGB LED strip with more than 2A total used across all three RGB channels:
- Metro GND to NeoRGB JST PH GND (black wire)
- Metro pin 6 to NeoRGB JST PH SIG (white wire)
- Power supply positive pin to NeoRGB terminal block VIN (red wire)
- Power supply negative pin to NeoRGB terminal block GND (black wire)
- NeoRGB RED to RGB strip red channel (pink wire)
- NeoRGB GRN to RGB strip green channel (green wire)
- NeoRGB BLU to RGB strip blue channel (blue wire)
- NeoRGB VIN to RGB strip VIN (red wire)
Library Installation
You can install the Adafruit NeoPixel library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries... menu item, search for Adafruit NeoPixel, and select the Adafruit NeoPixel library:
// SPDX-FileCopyrightText: 2024 Limor Fried for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif // Which pin on the Arduino is connected to the NeoPixels? // On a Trinket or Gemma we suggest changing this to 1: #define LED_PIN 6 // How many NeoPixels are attached to the Arduino? #define LED_COUNT 1 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // Argument 1 = Number of pixels in NeoPixel strip // Argument 2 = Arduino pin number (most are valid) // Argument 3 = Pixel type flags void setup() { // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. // Any other board, you can remove this part (but no harm leaving it): #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif // END of Trinket-specific code. strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255) } void loop() { rainbow(10); // Flowing rainbow cycle along the whole strip } // Rainbow cycle along whole strip. Pass delay time (in ms) between frames. void rainbow(int wait) { // Hue of first pixel runs 5 complete loops through the color wheel. // Color wheel has a range of 65536 but it's OK if we roll over, so // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time // means we'll make 5*65536/256 = 1280 passes through this loop: for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { // strip.rainbow() can take a single argument (first pixel hue) or // optionally a few extras: number of rainbow repetitions (default 1), // saturation and value (brightness) (both 0-255, similar to the // ColorHSV() function, default 255), and a true/false flag for whether // to apply gamma correction to provide 'truer' colors (default true). strip.rainbow(firstPixelHue); // Above line is equivalent to: // strip.rainbow(firstPixelHue, 1, 255, 255, true); strip.show(); // Update strip with new contents delay(wait); // Pause for a moment } }
Upload the sketch to your board. You'll see your RGB LED(s) cycle through a rainbow swirl animation.
You should keep in mind when you write your own code that if you are using a strip, all of the LEDs will act as one LED from a programming perspective since they aren't individually addressable. That means some effects may look flashier or more abrupt.
Text editor powered by tinymce.