Back to Phantom Modding - Neopixel LEDs

I've got the neo-pixels mounted on the legs. I put the Trinket, resistors, capacitors and all the connections on a padboard. And every things working fine.

Here is the board I made.



Here is where I mounted it on the Phantom.



And here's a pic with the lights on.



I'll make a video and post it when I get a chance to fly it, its going to be raining for a couple of days here.

I put extra connections on the board for 4 neo-pixel rings that I bought to install around the motors.

Many thanks to ElGuano for bringing this mod to the forums and his guidance on setting it up.
 
I've got the neo-pixel rings wired up and working. All I have to do is mount them on the Phantom.

Can a sketch be written that would let some lights (like the 4 on the legs) to read the naza led signal and the other lights (the 4 rings) to be green for front and red for back? Or would I have to get another Trinket for that?
 
djp4059 said:
I've got the neo-pixel rings wired up and working. All I have to do is mount them on the Phantom.

Can a sketch be written that would let some lights (like the 4 on the legs) to read the naza led signal and the other lights (the 4 rings) to be green for front and red for back? Or would I have to get another Trinket for that?

Sure you can. You can do it that way, you can have all the LEDs show orientation colors AND mirror LEDs, you can have one of the sticks do a knight rider sweep while another mirrors the NAZA and the rings show orientation...each LED is fully addressable and can be programmed independently. You can do it all from the same Trinket, assuming you have enough RAM...

The method in the code that controls the colors is below:
Code:
void playNoAnimation(unsigned long int animationColor) {
  for (byte i = 0; i < 8; i++) {

// show all 16 back directional colors, which all flash NAZA lights when lit up

    if (animationColor != 0x000000) {   // Assign rings to Naza Blink if not-black
      pixels.setPixelColor(i, animationColor);       // Back right (M4)
      pixels.setPixelColor(i+8, animationColor);    // Back left (M3)
      pixels.setBrightness(255);
    }
    
    else {                                         // otherwise assigns rings to directional color
      pixels.setPixelColor(i, 0xFF00FF);        // Back right arm (M4)
      pixels.setPixelColor(i+8, 0xFF00FF);     // Back left arm (M3)
      pixels.setBrightness(255);
    }
 }
  pixels.show();
}

ASSUMING your you have 16 x 4 LEDs for the rings, and they are wired in data series with 8 x 4 strips, you can change it like this (note that with 96 LEDs you're getting close to the maximum number of LEDs that fit in Trinket's ram, and putting a fairly high draw on your BEC if it's running at 2-3A) :

Code:
void playNoAnimation(unsigned long int animationColor) {
  for (byte i = 0; i < 96; i++) {

if (i < 32) {// show 8 x 4 sticks that mirror the NAZA colors ONLY, which all flash NAZA lights when lit up
      pixels.setPixelColor(i, animationColor);       // all sticks on legs to mirror NAZA
}
else if (i < 64) {
      pixels.setPixelColor(i, 0x00FF00);        // Back rings to green
    }

else {
      pixels.setPixelColor(i+8, 0xFF0000);     // front rings to red

}
}
pixels.setBrightness(255);
  pixels.show();
}

(Warning - code hasn't been tested so it may need to be tweaked/fixed, but should give you a sense of how to do it)

That's assuming your back rings are LEDs 32-63 and front rings are 64-95.
 
Well I got it all set up but have some problems getting all the lights to work at the same time. Tried the sketches in the above post but only the sticks would light up (at the time I thought the rings weren't working) tried your sketch from RCFORUMS for the rings and that worked (had to adjust the sketch for 4 rings and get the colors to work on the right rings). Know I have to figure out how to incorporate both sketches into one. I did have all the lights work at one time but the rings were all red, so I went and changed the colors and when I restarted only the sticks lit up. Will work on this again today when I get home from work.
 
djp4059 said:
Well I got it all set up but have some problems getting all the lights to work at the same time. Tried the sketches in the above post but only the sticks would light up (at the time I thought the rings weren't working) tried your sketch from RCFORUMS for the rings and that worked (had to adjust the sketch for 4 rings and get the colors to work on the right rings). Know I have to figure out how to incorporate both sketches into one. I did have all the lights work at one time but the rings were all red, so I went and changed the colors and when I restarted only the sticks lit up. Will work on this again today when I get home from work.

What do you have, 4 sticks and 4 rings? 96 lights is getting up to the RAM limit, and you may see weird behavior if you try to address them all. I'd try limiting it to 30-50 for the time being, and making sure they work, then addressing additional ones.

Also, a lot of it depends on the wiring. Is everything wired up in serial, with data in/out going from stick 1-4, then straight to rings 1-4? Or are you using separate digital out pins for any of the pixels? If you draw a diagram of how everything is wired up, it can help troubleshoot how the sketch should be set up.

Again, start simple - you can load up a strandtest and make sure all 96 rings are being addressed correctly. If that's the case, it's all a matter of getting the sketch right.
 
Thanks ElGuano, I have the data line in series, from the board to the 4 sticks and then to the 4 rings with the last ring having only a data in line. I'm going to do as you suggested and take a couple of the rings out of the loop and see what happens.
 
Turns out one of my rings wasn't working (maybe shorted or something) and naturally it was the first one in the data loop for the rings. So now I'm planning to just have the 4 sticks for NAZA and 2 rings (green) for directional on the front motors. Maybe I can find a spot on the back, for the 3rd one that still works, and make that one red for the rear.
 
djp4059 said:
Turns out one of my rings wasn't working (maybe shorted or something) and naturally it was the first one in the data loop for the rings

A failure like that would have kept me guessing for HOURS. I always default to something being wrong on the software side. Nice work isolating so quickly, and good luck getting everything back up :)

In the meantime, the mailman just delivered the sticks I need to finish my Phantom....and a few bigger parts for a new build!

0VhbSsG.jpg
 
A failure like that would have kept me guessing for HOURS. I always default to something being wrong on the software side.

It had me going there for awhile. I went back to step one and used your sketch from RCFORUMS and the rings didn't light up. They worked yesterday!!! First thought it was a bad connection, but that didn't pan out. So I took the first ring out and wallah it worked. Since I only have three rings now I'll use the first two on the motors in front and mount the other one on the battery door around the NAZA LED that I bought off of Deweys Shapeways page.

By the way, those are some pretty big rings you got there, I'd like to see what plans you have in store for them.
 
I got around to finishing the neopixel mod.

I added the two front sticks for a total of 32 LEDs, cleaned up the external wiring so they're entirely hidden. I did this at the same time as my P1 E300 motor/esc swap.

It's still a mess on the inside, but it looks fairly clean externally:
3dyC2UW.jpg


I decided not to modify the sticks or the shell to fit the clear lenses; it doesn't seem to greatly affect shell/arm integrity, and it would be a lot of work.
3fMMpue.jpg


Final result: Just like my Y6, front arms are purple, back arms are turquoise. Of course, they mirror the NAZA status LED, so whenever the NAZA flashes green/red/yellow, all four arms do exactly the same.
RROt5AS.jpg

uF7gqLe.jpg


This should look great at night. Hopefully I can get a quick picture or video this weekend.

You can see the half-finished versus the completed mod in this clip:
[youtube]http://www.youtube.com/watch?v=BFJX7KQyedc[/youtube]

And of course, an updated and cleaned up sketch for full front-and-back arms using 8 LEDs per arm.


Code:
/*

 Original DJI LED project
 Author(s): Yves Gohy ([email protected])
 Thanks to: Leandre Gohy ([email protected])
 
 Current fork: Basic Adafruit Trinket NAZA LED Adaptation
 Version: V1.0 June 14, 2014
 Author: El Guano on rcgroups.com, phantompilots.com
 Description: This version is modified to the Adafruit Trinket, particularly
 the implementation posted at 
 http://www.rcgroups.com/forums/showthread.php?t=2144784#post28061982.
 It is simplified from the original to save RAM and flash space; I also 
 didn't need RX-based controls or switchable animation modes, just basic 
 orientation and NAZA mimicry. 
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 For more detail on the MIT license, see <http://opensource.org/licenses/MIT>
 
 */

#include <Adafruit_NeoPixel.h>
//#include <math.h>

#define PIN 1 // LED output Pin (Pin 1 output is tied to the red LED on the Trinket)

#define BRIGHTNESS 30 // brightness 0-255  

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);

void setup() {
  pixels.begin();
  pixels.setBrightness(BRIGHTNESS);
  pinMode(2, INPUT);  // GPIO pins 2 and 4 for analogRead
  pinMode(4, INPUT);
}

unsigned long int getAnimationColor() {
  static const unsigned long int animationColors[] = { 
    0x000000, 0x00FF00, 0xFF0000, 0xFFFF00       }; // colors of animation OFF, GREEN, RED, YELLOW
  static unsigned long int animationColor = 0x000000;
  // read Naza green led
  int sensorValue0 = analogRead(1);  //Digital pin 2 is Analog 1 on Trinket
  // read Naza red led
  int sensorValue1 = analogRead(2);   //Digital pin 4 is Analog 2 on Trinket
  
  byte animationColorIndex = (sensorValue0 > 500) + ((sensorValue1 > 500) << 1); // e.g., 1 + 2 = 3 (yellow), 0 + 2 = 2 (red)

  animationColor = animationColors[animationColorIndex];

  return animationColor;
}


void playNoAnimation(unsigned long int animationColor) {
  for (byte i = 0; i < 8; i++) {

// show all 16 back directional colors, which all flash NAZA lights when lit up

    if (animationColor != 0x000000) {           // Assign rings to Naza Blink if not-black
      pixels.setPixelColor(i, animationColor);       // Back right (M4)
      pixels.setPixelColor(i+8, animationColor);     // Back left (M3)
      pixels.setPixelColor(i+16, animationColor);    // Front left (M2)
      pixels.setPixelColor(i+24, animationColor);    // Front right (M1)
    }
    
    else {                                    // otherwise assigns rings to directional color
      pixels.setPixelColor(i, 0x00FFFF);        // Back right arm (M4)
      pixels.setPixelColor(i+8, 0x00FFFF);      // Back left arm (M3)
      pixels.setPixelColor(i+16, 0xFF00FF);     // Front left arm (M2)
      pixels.setPixelColor(i+24, 0xFF00FF);     // Front right arm (M1)
    }
 }
 pixels.setBrightness(255);
  pixels.show();
}

void loop() {
  unsigned long int animationColor = getAnimationColor();
  playNoAnimation(animationColor);
}
 
Here are a couple of pics and a video of the completed neopixel mod at night. One thing that's clear is that it's far TOO bright for FPV at night, with how far my gimbal/gopro are pushed forward on the frame. I'll need to drop the brightness on the front arms for sure.

Here's where I think djp really got it right--I should have externally mounted the Trinket. The way I have it inside the shell, I can't access it to replace the sketch unless I unscrew and open the top shell. Oops!

042r1xU.jpg


2D9TRsD.jpg


http://www.youtube.com/watch?v=FffOzyMJTNs

Btw, that artificial horizon on the iOSD video is correct and I was in hover with hands off sticks. It's crazy windy tonight, I probably shouldn't have been flying as it is...
 
Here's where I think djp really got it right--I should have externally mounted the Trinket. The way I have it inside the shell, I can't access it to replace the sketch unless I unscrew and open the top shell. Oops!

Looks good ElGuano, I'm like you, I like to put everything in the shell too, that way the Phantom looks nice and clean, but I really hate taking that shell off every time I have to work on something.
 
ElGuano, I really like this mod!

But I was wondering about a few things..

Can the Naza still be connected and updated through the USB port on the LED with the Trinket connected?
Can it be programmed to use the PWM input from a spare receiver channel to dim or even turn off the LED's?
 
Squawk said:
ElGuano, I really like this mod!

But I was wondering about a few things..

Can the Naza still be connected and updated through the USB port on the LED with the Trinket connected?
Can it be programmed to use the PWM input from a spare receiver channel to dim or even turn off the LED's?

Yes, the trinket doesn't interfere with USB. You can set it, forget it, and still connect to Assistant and read/write changes and upgrade firmware without issue.

Yes! I don't have this setup as I'm on the stock 1-pin receiver, but you can do exactly as you describe--specify LED function based on PMW range via pulseIn to a separate pin on the Arduino. You can have a switch change between animations/brightness, or a pin tied to elevator/throttle and speed up animation or activate different lights based on stick position. I'm also working on a canBUS mod that can do things like blink on velocity/acceleration or height/distance, spin the rings to have certain colors always face north or home, etc.
 
Heh, nice! You can always grab and integrate the code into the Naza flashes if you want, if you're into the sparkly vampire thing ;)

Not quite sure what that comment is about 255 being "1/3 brightness" though...afaik 255 is max.
 
ElGuano said:
Squawk said:
ElGuano, I really like this mod!

But I was wondering about a few things..

Can the Naza still be connected and updated through the USB port on the LED with the Trinket connected?
Can it be programmed to use the PWM input from a spare receiver channel to dim or even turn off the LED's?

Yes, the trinket doesn't interfere with USB. You can set it, forget it, and still connect to Assistant and read/write changes and upgrade firmware without issue.

Yes! I don't have this setup as I'm on the stock 1-pin receiver, but you can do exactly as you describe--specify LED function based on PMW range via pulseIn to a separate pin on the Arduino. You can have a switch change between animations/brightness, or a pin tied to elevator/throttle and speed up animation or activate different lights based on stick position. I'm also working on a canBUS mod that can do things like blink on velocity/acceleration or height/distance, spin the rings to have certain colors always face north or home, etc.


Thanks! That is nice info..

So, now the only thing for me to do is figure out how to program.. :(
 
I put the Neo-pixels on my F550 FlameWheel. I mounted the sticks on the landing gear that reflect what the NAZA LED puts out, And I have 6 rings on the motors (2 are green so I know where the front of the craft is, and the other 4 are just for show). Here's a short video of it in flight at night. https://www.youtube.com/watch?v=5HbzjR3 ... e=youtu.be


[youtube]5HbzjR3JBLo[/youtube]
 
That looks AMAZING! Great job! You did what I've been wanting to do, which is to install the LEDs pointing upwards into the props so it's visible at night. You NEED to get yourself some of the white e300 props, they reflect 2-3x as brightly as do the grays :)

I take it the red/blue lights are on a cyclic pattern and aren't responding to throttle input or anything?
 
Since this got bumped, a quick update on the Phantom and Y6 ends:

On the Phantom, I remounted the trinket and cut a port in the shell for the USB--now I can update the sketch and change the animation patterns without removing the shell:
BIxy6R2.jpg


On the new Y6, I did the same mod with the 24-LED rings, along with a single LED on each arm facing upwards so it's visible when the hex is below the pilot:
e5o8Rsc.jpg


0ny7v5j.jpg


At night, the props make for some unreal 3D effects under the lights:
[youtube]https://www.youtube.com/watch?v=01sWr4chIOA[/youtube]
 

Recent Posts

Members online

No members online now.

Forum statistics

Threads
143,094
Messages
1,467,590
Members
104,977
Latest member
wkflysaphan4