Messing around with this for awhile.

Messing around with this for awhile. Would love to Bluetooth the control side of this but for now it just loops through a few sequences. I’m not very proficient coding but it works.

#include “FastLED.h”
#define NUM_LEDS 60
#define DATA_PIN 13
#define COLOR_ORDER GRB
struct CRGB leds[NUM_LEDS];
//CRGB leds[NUM_LEDS];
int count = 0;
int f = 0; //Front
int l = 0; //Left
int b = 0; //Back
int r = 0; //Right
int fd = (NUM_LEDS/4*3); //Front
int bd = (NUM_LEDS/4); //Back
int rd = (NUM_LEDS/2); //Right
int timer = 30;
int timer2 = 10;
int cycle = 0;
int bright = 32;
int scale = 0;
uint8_t thisdelay = 8; // A delay value for the sequence(s)
volatile long previousMillis = 0;

//Direction Arrays
int FwdArray[] = { //Forward
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59};
int RevArray[] = { //Reverse
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45};
int ScanArray[] = { //Scan
59, 45, 58, 46, 57, 47, 56, 48, 55, 49, 54, 50, 53, 51, 52};

void setup() {
delay(2000);
LEDS.setBrightness(bright);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
// LEDS.addLeds<NEOPIXEL, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
// Serial.begin(9600);
}
void Basic() {
for (count=0;count<=14;count++)
{
f=(ScanArray[count]fd);
r=(FwdArray[count]-rd);
b=(ScanArray[count]-bd);
l=(RevArray[count]);
leds[f] = CRGB::Red;
leds[b] = CRGB::Green;
FastLED.show();
leds[l] = CRGB::Black;
leds[r] = CRGB::Black;
delay(timer);
}
for (count=14;count>=0;count-)
{
f=(ScanArray[count]fd);
r=(FwdArray[count]-rd);
b=(ScanArray[count]-bd);
l=(RevArray[count]);
leds[f] = CRGB::Red;
leds[b] = CRGB::Green;
leds[l] = CRGB::Blue;
leds[r] = CRGB::Blue;
FastLED.show();
leds[f] = CRGB::Black;
leds[b] = CRGB::Black;
delay(timer);
}
}

void Cylon() {
for (count=0;count<=14;count++)
{
f=(ScanArray[count]-fd);
r=(ScanArray[count]-rd);
b=(ScanArray[count]-bd);
l=(ScanArray[count]);
leds[f] = CRGB::DarkMagenta;
leds[b] = CRGB::DarkMagenta;
leds[r] = CRGB::DarkMagenta;
leds[r] = CRGB::DarkMagenta;
FastLED.show();
leds[l] = CRGB::Black;
leds[r] = CRGB::Black;
leds[f] = CRGB::Black;
leds[b] = CRGB::Black;
delay(timer2);
}
for (count=14;count>=0;count-)
{
f=(ScanArray[count]fd);
r=(ScanArray[count]-rd);
b=(ScanArray[count]-bd);
l=(ScanArray[count]);
leds[f] = CRGB::DarkMagenta;
leds[b] = CRGB::DarkMagenta;
leds[l] = CRGB::DarkMagenta;
leds[r] = CRGB::DarkMagenta;
FastLED.show();
// leds[f] = CRGB::Black;
// leds[b] = CRGB::Black;
delay(timer2);
}
// fade down by scaling the brightness
for(int scale = (bright); scale >= (bright/6); scale-) {
LEDS.showColor(CRGB::DarkMagenta, scale);
delay(timer2);
}
// fade up by scaling the brightness
for(int scale = (bright/6); scale <=(bright); scale++) {
LEDS.showColor(CRGB::DarkMagenta, scale);
delay(timer2/2);
}
}

void Rainbow(uint8_t wait)
{
uint16_t hue;
FastLED.clear();
for(hue=10; hue<255*3; hue++)
{
fill_rainbow( &(leds[0]), NUM_LEDS /led count/, hue /starting hue/);
FastLED.show();
delay(wait);
}
return;
}
void twinkle() {
int i = random8(); // A random number. Higher number => fewer twinkles. Use random16() for values >255.
if (i < NUM_LEDS) leds[i] = CHSV(50, 100, 255); // Only the lowest probability twinkles will do. You could even randomize the hue/saturation. .
for (int j = 0; j < NUM_LEDS; j++) leds[j].fadeToBlackBy(8);
// show_at_max_brightness_for_power(); // Power managed display of LED’s
LEDS.show(); // Standard FastLED display
delay(thisdelay); // Old style blocking delay
}

void loop() {
for (cycle=2000;cycle>=0;cycle-)
{
twinkle();
}
for (cycle=20;cycle>=0;cycle-)
{
Basic();
}
for (cycle=20;cycle>=0;cycle–)
{
Cylon();
}
Rainbow(20);

}

//

8833456120617f2ecd49ae6d8fb57380.gif

That’s how I started - I haven’t touched a plane or a copter for more than six months now. :slight_smile: My flight toolbox is full of really cool new parts - still in their packets. My workshop bench is now a morass of cables, modules, breadboards, computers, connectors, power supplies, etc.

I thought it would be a nice cheap hobby that could work with my RC’ing -it’s ended up costing SO MUCH MORE! (if that’s possible with RC).

Good luck! (I’ve got a nice piece of code that sets up ‘nav zones’ for the Phantom so that the red/blue bits at the end of the copter arms stays static, so you don’t get lost flying at night).

I dont know if the DJI NAZA flight controller could output data but if possible you could control the lights (change colors and pattern) with the gyros, altitude, direction and acceleration.

Alternately, you might be able to use telemetry modules to provide data to the light controller. A separate 9 axis module might give you the needed data.

So how does it fly with the lights? Any changes in control response or flight time?

And RC can be mad expensive - I have the DJI Phantom, S800, 330, 450 and 550 plus I’m building a Tarot 650.

@Michael_Sharnet
Flight times are about 1 min. less and she’s a little sluggish on takeoff. This is a Dji 1.1.1 Phantom and doesn’t have a lot of connectivity. Would be pretty easy to add a few modules to the arduino pro mini, allowing changes in altitude and direction to be detected.
I just picked up a Tarot 680 frame for $70 and plan on using the Pixahawk flight controller. But it’s going to take awhile to build as I nickel and dime it in to reality.

FYI I use the same DJI Naza on multiple copters to save $. I get batteries and other parts from HobbyKing.com. Typically I try to order stuff to get the best shipping cost the trade off is time. It sometimes takes more than 30 days for stuff to arrive.

I buy from BangGood or GoodLuckyBuy also eBay. Average shipping time has been 3 weeks. Prices are good and customer service from BangGood has been great!

@Mike_Eden I’ve got a 1.1.1 - I used the spare channel on the back of the controller to cycle through patterns - it’s really easy. You can also use a combination of switches. There’s a library somewhere for reading PWM and there’s a specific one for the Naza from the Arduino flight controller forums.

Thanks Mike! I will check into it

OMG! What are you using for a power supply?

Battery? Those LEDs only need 5v

@Mike_Eden how did you get on?

You can either use a step down voltage regulator or pull power from one cell of the battery through the balance plug. Just make sure you connect to only one cell (test it with a meter between two adjacent terminals on the balance plug. Your meter should read between 3.4 and 4.3 volts). Most of the time WS2812 are able to run on less than 5v. And lower voltage means lower current which in theory should make the LEDs last longer.

Step down regulator link: http://www.ebay.com/itm/New-Mini-DC-DC-Buck-Converter-Step-Down-Module-Power-Supply-For-aeromodelling-/181639814725?pt=LH_DefaultDomain_0&hash=item2a4a939e45