Arduino Libraries

To use the Daftpunk BLE sketch you'll want to make sure you're using the latest version of the Arduino IDE (1.6.5 at the time of this writing).

If you're totally new to Arduino take a little time to go through some introductory tutorials like how to make a LED blink.  This will help you understand how to use the IDE, load a sketch, and upload code.

Next you'll need to make sure the libraries used by the sketch are installed.  With the latest Arduino IDE you can use its library manager to easily install libraries, or check out this guide on how to manually install a library.  You'll want to install the following libraries:

  • Adafruit BluefruitLE nRF51
  • Adafruit NeoPixel

Search for the libraries in the library manager and they should be easy to find and install.

Adafruit AVR Boards

Next, you'll need to install the Adafruit AVR boards package from the Boards Manager. Open the Boards Manager and search for Adafruit AVR. This includes all of the boards from Adafruit and will make Arduino compatabile with them. The Daftpunk BLE sketch was tested with version 1.4.0.

Uploading Sketch to Adafruit Feather BLE

This sketch will run the Bluetooth controlled LED program to the NeoPixel strips that are mounted to the front of the visor.

To load the sketch make sure the libraries above are installed, and the Arduino is connected to the computer through a USB cable.  Under the Tools -> Board menu make sure the Adafruit Feather 32u4 is selected, and under the Tools -> Port menu the serial port for the Adafruit Feather is selected.  

Then press the upload button or click the Sketch -> Upload item to send the code to the Arduino.  Woo-hoo the sketch should be running.

Connect Adafruit BLE Mobile App to Adafruit Feather BLE

Download the Adafruit BLE Connect app for iOS or Android. Under the peripherals list, tap the connect button on the Adafruit Bluefruit LE item. Make sure the Feather board is powered on. Select "Controller" and choose either Control Pad or the Color Picker.

Control Pad

Buttons 1-4 will trigger an animation.

  1. larsonScanner
  2. color wipe
  3. rainbow gradient
  4. rainbow cycle

Color Picker

Here you can change the brightness or RGB value of the leds. 

Uploading Sketch to Adaruit 5V Trinket

If you like to power the NeoPixel Rings separately from the NeoPixel strips in the visor, you can use a separate sketch that's included with the Adafruit NeoPixel Library: strandtest.

It's been slightly modified to only loop through the rainbwCycle animation.

To upload the sketch to the Adafruit 5V Trinket, select Adafruit Trinket 16MHz from the Boards option under the Tools menu. Then, choose the USBtinyISP option under Programmer in the Tools menu. Be sure a USB cable is plugged into the 5V Trinket and your computer. When the red LED pulses on the Trinket, hit the upload button. It should upload then the sketch.

Download: file
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 0

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code


  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  rainbowCycle(10);
}


// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

Upload and Test Circuit

Once the code is uploaded to the micro-controllers, its a good idea to protoptype the circuit using the diagram in the previous page. Test the NeoPixel Strip and a single NeoPixel Ring to ensure the components are functional. Try out the Adafruit Feather 32u4 Bluefruit LE and run the Adafruit Bluefruit LE Connect iOS/Android app. Play with the controls and use the color picker to change the colors of the NeoPixels.

This guide was first published on Dec 29, 2015. It was last updated on Dec 29, 2015. This page (Code) was last updated on Sep 22, 2019.