These holiday lights can be controlled right from your smartphone or tablet. Just open the Bluefruit LE app and use its color picker to choose the best color for any celebration.
Parts
To build these lights you'll need the following parts:
- Bluefruit LE Feather
- NeoPixels
- You can use a strip, ring, matrix, or even bare pixels. Just make sure your power supply can handle all the pixels you intend to use!
- 5V Power Supply
- I recommend the 5 volt 10 amp supply as it can handle lighting up to about 150 NeoPixels. Remember each pixel can take up to 60mA alone! Also a DC power jack terminal adapter makes it easy to connect a power supply to the circuit.
- Breadboard, jumper wires, and soldering tools.
Wiring
First follow the guide for each component to assemble and test it:
Then wire up the components as shown below:
- Connect power supply ground to Bluefruit LE Feather ground and NeoPixel ground.
- Connect power supply 5V to Bluefruit LE Feather USB pin and NeoPixel +5V.
- Connect Bluefruit LE Feather pin 6 to NeoPIxel signal input (Din).
Sketch
Before loading the sketch make sure you have the following libraries installed. Remember you can use the Arduino library manager to easily search for and install them:
Next download the sketch from its home on GitHub which contains three files under the Feather_BluefruitLE_Lights folder:
Click Download: Project Zip in the main code window below.
// SPDX-FileCopyrightText: 2019 Tony DiCola for Adafruit Industries // // SPDX-License-Identifier: MIT // Adafruit Bluefruit LE Feather Holiday Lights // See the full guide at: // https://learn.adafruit.com/feather-holiday-lights/overview // Author: Tony DiCola // Based on the neopixel_picker example from the Adafruit Bluefruit nRF51 library. // Released under a MIT license: // https://opensource.org/licenses/MIT #include "Adafruit_BLE.h" #include "Adafruit_BluefruitLE_SPI.h" #include "Adafruit_NeoPixel.h" #include "BluefruitConfig.h" #include "SoftwareSerial.h" #include "SPI.h" #define PIXEL_COUNT 60 // The number of NeoPixels connected to the board. #define PIXEL_PIN 6 // The pin connected to the input of the NeoPixels. #define PIXEL_TYPE NEO_GRB + NEO_KHZ800 // The type of NeoPixels, see the NeoPixel // strandtest example for more options. #define ANIMATION_PERIOD_MS 300 // The amount of time (in milliseconds) that each // animation frame lasts. Decrease this to speed // up the animation, and increase it to slow it down. // Create NeoPixel strip from above parameters. Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); // Create the Bluefruit object using hardware SPI (for Bluefruit LE feather). Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST); // Global variable to hold the current pixel color. Starts out red but will be // changed by the BLE color picker. int r = 255; int g = 0; int b = 0; // Function prototypes and data over in packetparser.cpp uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout); float parsefloat(uint8_t *buffer); void printHex(const uint8_t * data, const uint32_t numBytes); extern uint8_t packetbuffer[]; void setup(void) { Serial.begin(115200); Serial.println(F("Adafruit Bluefruit LE Holiday Lights")); // Initialize NeoPixels. strip.begin(); strip.show(); // Initialize BLE library. if (!ble.begin(false)) { Serial.println(F("Couldn't find Bluefruit LE module!")); while (1); } ble.echo(false); Serial.println(F("Please use Adafruit Bluefruit LE app to connect in Controller mode")); Serial.println(F("Then activate/use the color picker to change color.")); Serial.println(); // Wait for connection. while (!ble.isConnected()) { // Make sure to animate the pixels while waiting! animatePixels(strip, r, g, b, ANIMATION_PERIOD_MS); delay(50); } ble.setMode(BLUEFRUIT_MODE_DATA); } void loop(void) { // Animate the pixels. animatePixels(strip, r, g, b, ANIMATION_PERIOD_MS); // Grab a BLE controller packet if available. uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT); if (len == 0) return; // Parse a color packet. if (packetbuffer[1] == 'C') { // Grab the RGB values from the packet and change the light color. r = packetbuffer[2]; g = packetbuffer[3]; b = packetbuffer[4]; // Print out the color that was received too: Serial.print ("RGB #"); if (r < 0x10) Serial.print("0"); Serial.print(r, HEX); if (g < 0x10) Serial.print("0"); Serial.print(g, HEX); if (b < 0x10) Serial.print("0"); Serial.println(b, HEX); } } void animatePixels(Adafruit_NeoPixel& strip, uint8_t r, uint8_t g, uint8_t b, int periodMS) { // Animate the NeoPixels with a simple theater chase/marquee animation. // Must provide a NeoPixel object, a color, and a period (in milliseconds) that controls how // long an animation frame will last. // First determine if it's an odd or even period. int mode = millis()/periodMS % 2; // Now light all the pixels and set odd and even pixels to different colors. // By alternating the odd/even pixel colors they'll appear to march along the strip. for (int i = 0; i < strip.numPixels(); ++i) { if (i%2 == mode) { strip.setPixelColor(i, r, g, b); // Full bright color. } else { strip.setPixelColor(i, r/4, g/4, b/4); // Quarter intensity color. } } strip.show(); }
Unzip the archive and load the Feather_BluefruitLE_Lights sketch in the Arduino IDE.
Near the top of the sketch are #define values that you can adjust to suite your light configuration:
- PIXEL_COUNT - Set this to the number of NeoPixels you're using.
- PIXEL_PIN - Set this to the pin connected to the NeoPixel input (pin 6 if you followed the wiring).
- PIXEL_TYPE - Set this to the type of NeoPixel. Use the default unless you know you're using a different type of NeoPixel (see the strandtest example in the NeoPixel library for more information on types of NeoPixels).
- ANIMATION_PERIOD_MS - This is the amount of time a single animation frame takes (in milliseconds). Adjust this to slow down and speed up the animation.
Upload the sketch to your hardware and you should see the lights turn on and animate with a red color. Now use the Bluefruit LE app on an iOS or Android device and connect to the Bluefruit Feather in Controller mode. Use the Color Picker to pick a color and send it to the Bluefruit--woo hoo, the lights will change color!
Check out the Bluetooth NeoPixel Goggles project for a little more explanation about using the color picker.
That's all there is to the Bluefruit LE Feather holiday light project! Use the color picker on your phone/table to control your holiday lights with ease!
Page last edited January 22, 2025
Text editor powered by tinymce.