Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Lightsaber brightness 3W RGB LED
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Lightsaber brightness 3W RGB LED

by axlg on Mon Jun 29, 2020 12:19 pm

Hello guys, I cant make the 3W rgb led to go super brightness, its very dim, I dont know if this is right or I am doing something wrong. I already tested a different rgb led with same result.

I have theconnections like this:
01.png
01.png (303.82 KiB) Viewed 273 times


Then for the rgb led im using this:
02.png
02.png (570.22 KiB) Viewed 273 times


Im using 4400mah batteries

Any idea of what can it be the problem?
04.png
04.png (215.43 KiB) Viewed 273 times


Thanks. Regards.

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Mon Jun 29, 2020 10:20 pm

1. This is an "accessory board" which is mated to a microcontroller board. What do you you have it attached to since I don't think you run it standalone?
2.
Code: Select all | TOGGLE FULL SIZE
 https://learn.adafruit.com/adafruit-prop-maker-featherwing/overview
is the guide for using it. It looks like the POWER connection needs to be enabled(through code) so that the led pads are activated.
Good luck.

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Re: Lightsaber brightness 3W RGB LED

by axlg on Thu Jul 02, 2020 11:37 am

Hello, thanks for the reply. Im doing this one:

https://learn.adafruit.com/lightsaber-f ... g?view=all


Instead of using the 3W rgb led im using other brand that can go up to 500 lumens, but worse result. I dont really think right now that the problem is the code.

My idea is to make the lightsaber like a flashlight but with rgb colors, effects, etc. Like the Prop-Maker Lightsaber with the option to use or not a tube.
I saw some in youtube that are very bright but im very far from that.
I have a flashlight with only one led that is like 1000 lumens, I think I will disassemble it and test with that LED haha.

Regards.

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Thu Jul 02, 2020 3:11 pm

I'm taking a guess but the LED you are trying to use may be a 12v version usually used for auto systems which might explain the dim lights. These boards are usually run with 5v power, and getting 3.3 or 5 volt signals out of the pins. Connecting high power components may damage the boards when they operate so proceed with caution.

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Re: Lightsaber brightness 3W RGB LED

by axlg on Fri Jul 03, 2020 3:42 pm

I was trying this one: (dont know if I can put external links)

https://www.ledsupply.com/leds/luxeon-r ... -power-led

It says:

3.15Vf (Blue) - Forward Voltage 350mA
2.90Vf (Red)- Forward Voltage 350mA
3.15Vf (Green) - Forward Voltage 350mA


The pins of Adafruit Prop-Maker FeatherWing im using for the led:

Blue - Blue pin for 3W RGB LED - connected through a MOSFET. Connected to D13 on Feather M0 or M4.
Green - Green pin for 3W RGB LED - connected through a MOSFET. Connected to D12 on Feather M0 or M4.
Red - Red pin for 3W RGB LED - connected through a MOSFET. Connected to D11 on Feather M0 or M4.
Power (PWR) - This pin is used to enable power to the NeoPixels, audio amplifier and RGB LED. By default it is pulled low so you must set high to turn on the NeoPixels/Audio/RGB. Connected to D10 on Feather M0 or M4.

The 3W RGB LED I tested too say:
Each of the red, green, and blue dice can handle continuous ~350mA current draw (with peaks of 1000mA).

So I imagine the feather can handle that current draw for the leds I tested.

Anyways, If I connect for exmaple the 3W rgb led (only one color) to a DC power supply, at 3,2v, it draw 1,7A ! (it is 5,44 watts!), And it get super bright.

If for exmaple I add a 10 omh resistor, it will draw only 130mA, and still is a lot more bright than when I have it connected to the feather. I think the problem here is more electronic, and im not very good on that haha. I will continue with some experiments.

Regards.

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Fri Jul 03, 2020 4:06 pm

Power (PWR) - This pin is used to enable power to the NeoPixels, audio amplifier and RGB LED. By default it is pulled low so you must set high to turn on the NeoPixels/Audio/RGB. Connected to D10 on Feather M0 or M4.


Just trying to help but I don't know what microcontroller board you have (which is necessary for the wing to work) mated to the featherwing that should be driving the featherwing. In code you would have to "enable" the power going to the RGB hookup connections on the featherwing or else you get minimal power there. I don't think you can just jumper it either.

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Re: Lightsaber brightness 3W RGB LED

by axlg on Fri Jul 03, 2020 4:17 pm

Sorry, that is why I said I was making the Prop-Maker Lightsaber

https://learn.adafruit.com/lightsaber-f ... g?view=all

And the only different is that i am using those leds instead of neopixels.

Im using the Adafruit Prop-Maker FeatherWing with Adafruit Feather M4 Express - Featuring ATSAMD51 - ATSAMD51 Cortex M4.


In code you would have to "enable" the power going to the RGB hookup connections on the featherwing or else you get minimal power there. I don't think you can just jumper it either.


Can you help me more with that?

My code (is the one of the Prop-Maker Lightsaber with a little changes but minimal)

Code: Select all | TOGGLE FULL SIZE
# pylint: disable=bare-except

import time
import math
from digitalio import DigitalInOut, Direction, Pull
import audioio
import busio
import board
import neopixel
import adafruit_lis3dh
import gc

#import adafruit_dotstar
import pulseio
import random


# CUSTOMIZE YOUR COLOR HERE:
COLOR = (0, 100, 255)  # cyan

# CUSTOMIZE SENSITIVITY HERE: smaller numbers = more sensitive to motion
HIT_THRESHOLD = 325
SWING_THRESHOLD = 175

NUM_PIXELS = 85
NEOPIXEL_PIN = board.D5
POWER_PIN = board.D10
SWITCH_PIN = board.D9

enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = False

#red_led = DigitalInOut(board.D11)
#red_led.direction = Direction.OUTPUT
#green_led = DigitalInOut(board.D12)
#green_led.direction = Direction.OUTPUT
#blue_led = DigitalInOut(board.D13)
#blue_led.direction = Direction.OUTPUT


audio = audioio.AudioOut(board.A0)     # Speaker
mode = 0                               # Initial mode = OFF

strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=1, auto_write=False)
strip.fill(0)                          # NeoPixels off ASAP on startup
strip.show()

led = neopixel.NeoPixel(board.NEOPIXEL, 1)  # NeoPixel de la board
led[0] = (0, 0, 100)

switch = DigitalInOut(SWITCH_PIN)
switch.direction = Direction.INPUT
switch.pull = Pull.UP


# variable de 0 a 255
def duty_cycle_value(var):
     return int(var * 257)

led_ROJO = pulseio.PWMOut(board.D11, frequency=50000)   # boton led ROJO
led_VERDE = pulseio.PWMOut(board.D12, frequency=50000)   # boton led VERDE
led_AZUL = pulseio.PWMOut(board.D13, frequency=50000)   # boton led AZUL



def boton_color_final(rgb_color2):
    led_ROJO.duty_cycle = duty_cycle_value((rgb_color2[0] & 0xFF) / 3.3)
    led_VERDE.duty_cycle = duty_cycle_value((rgb_color2[1] & 0xFF) / 1.4)
    led_AZUL.duty_cycle = duty_cycle_value((rgb_color2[2] & 0xFF) / 1)

boton_color_final(COLOR)


time.sleep(0.1)

# Set up accelerometer on I2C bus, 4G range:
i2c = busio.I2C(board.SCL, board.SDA)
accel = adafruit_lis3dh.LIS3DH_I2C(i2c)
accel.range = adafruit_lis3dh.RANGE_4_G

# "Idle" color is 1/4 brightness, "swinging" color is full brightness...
COLOR_IDLE = (int(COLOR[0] / 3), int(COLOR[1] / 3), int(COLOR[2] / 3))
COLOR_SWING = COLOR
COLOR_HIT = (255, 255, 255)  # "hit" color is white

def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3)


def play_wav(name, loop=False):
    """
    Play a WAV file in the 'sounds' directory.
    @param name: partial file name string, complete name will be built around
                 this, e.g. passing 'foo' will play file 'sounds/foo.wav'.
    @param loop: if True, sound will repeat indefinitely (until interrupted
                 by another sound).
    """
    print("playing", name)
    try:
        wave_file = open('sounds/' + name + '.wav', 'rb')
        wave = audioio.WaveFile(wave_file)
        audio.play(wave, loop=loop)
    except:
        return

def power(sound, duration, reverse):
    """
    Animate NeoPixels with accompanying sound effect for power on / off.
    @param sound:    sound name (similar format to play_wav() above)
    @param duration: estimated duration of sound, in seconds (>0.0)
    @param reverse:  if True, do power-off effect (reverses animation)
    """
    if reverse:
        prev = NUM_PIXELS
    else:
        prev = 0
    gc.collect()                   # Tidy up RAM now so animation's smoother
    start_time = time.monotonic()  # Save audio start time
    play_wav(sound)
    while True:
        elapsed = time.monotonic() - start_time  # Time spent playing sound
        if elapsed > duration:                   # Past sound duration?
            break                                # Stop animating
        fraction = elapsed / duration            # Animation time, 0.0 to 1.0
        if reverse:
            fraction = 1.0 - fraction            # 1.0 to 0.0 if reverse
        fraction = math.pow(fraction, 0.5)       # Apply nonlinear curve
        threshold = int(NUM_PIXELS * fraction + 0.5)
        num = threshold - prev  # Number of pixels to light on this pass
        if num != 0:
            if reverse:
                strip[threshold:prev] = [0] * -num
            else:
                strip[prev:threshold] = [COLOR_IDLE] * num
            strip.show()
            # NeoPixel writes throw off time.monotonic() ever so slightly
            # because interrupts are disabled during the transfer.
            # We can compensate somewhat by adjusting the start time
            # back by 30 microseconds per pixel.
            start_time -= NUM_PIXELS * 0.00003
            prev = threshold

    if reverse:
        strip.fill(0)                            # At end, ensure strip is off
    else:
        strip.fill(COLOR_IDLE)                   # or all pixels set on
    strip.show()
    while audio.playing:                         # Wait until audio done
        pass

def mix(color_1, color_2, weight_2):
    """
    Blend between two colors with a given ratio.
    @param color_1:  first color, as an (r,g,b) tuple
    @param color_2:  second color, as an (r,g,b) tuple
    @param weight_2: Blend weight (ratio) of second color, 0.0 to 1.0
    @return: (r,g,b) tuple, blended color
    """
    if weight_2 < 0.0:
        weight_2 = 0.0
    elif weight_2 > 1.0:
        weight_2 = 1.0
    weight_1 = 1.0 - weight_2
    return (int(color_1[0] * weight_1 + color_2[0] * weight_2),
            int(color_1[1] * weight_1 + color_2[1] * weight_2),
            int(color_1[2] * weight_1 + color_2[2] * weight_2))

# Main program loop, repeats indefinitely
while True:



    if not switch.value:                    # button pressed?
        if mode == 0:                       # If currently off...
            enable.value = True
            power('on', 1.7, False)         # Power up!
            play_wav('idle', loop=True)     # Play background hum sound
            mode = 1                        # ON (idle) mode now
        else:                               # else is currently on...
            power('off', 1.15, True)        # Power down
            mode = 0                        # OFF mode now
            enable.value = False
        while not switch.value:             # Wait for button release
            time.sleep(0.2)                 # to avoid repeated triggering

    elif mode >= 1:                         # If not OFF mode...
        x, y, z = accel.acceleration  # Read accelerometer
        accel_total = x * x + z * z
        # (Y axis isn't needed for this, assuming Hallowing is mounted
        # sideways to stick.  Also, square root isn't needed, since we're
        # just comparing thresholds...use squared values instead, save math.)
        if accel_total > HIT_THRESHOLD:   # Large acceleration = HIT
            TRIGGER_TIME = time.monotonic()  # Save initial time of hit
            play_wav('hit')                  # Start playing 'hit' sound
            COLOR_ACTIVE = COLOR_HIT         # Set color to fade from
            mode = 3                         # HIT mode
        elif mode is 1 and accel_total > SWING_THRESHOLD:  # Mild = SWING
            TRIGGER_TIME = time.monotonic()  # Save initial time of swing
            play_wav('swing')                # Start playing 'swing' sound
            COLOR_ACTIVE = COLOR_SWING       # Set color to fade from
            mode = 2                         # SWING mode
        elif mode > 1:                       # If in SWING or HIT mode...
            if audio.playing:                # And sound currently playing...
                blend = time.monotonic() - TRIGGER_TIME  # Time since triggered
                if mode == 2:                # If SWING,
                    blend = abs(0.5 - blend) * 2.0  # ramp up, down
                strip.fill(mix(COLOR_ACTIVE, COLOR_IDLE, blend))
                strip.show()
                led.fill(mix(COLOR_ACTIVE, COLOR_IDLE, blend))              # color del led de la board
                led.show()
                boton_color_final(mix(COLOR_ACTIVE, COLOR_IDLE, blend))     # color del boton rgb
            else:                            # No sound now, but still MODE > 1
                play_wav('idle', loop=True)  # Resume background hum
                strip.fill(COLOR_IDLE)       # Set to idle color
                strip.show()
                led.fill(COLOR_IDLE)            # color del led de la board
                led.show()
                boton_color_final(COLOR_IDLE)   # color del boton rgb
                mode = 1                     # IDLE mode now


Regards.

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Fri Jul 03, 2020 4:36 pm

try change last line
Code: Select all | TOGGLE FULL SIZE
enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = False

to
Code: Select all | TOGGLE FULL SIZE
enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = True


(make sure uppercase "T" - should see it as a keyword your editor)

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Fri Jul 03, 2020 4:39 pm

Code: Select all | TOGGLE FULL SIZE
#red_led = DigitalInOut(board.D11)
#red_led.direction = Direction.OUTPUT
#green_led = DigitalInOut(board.D12)
#green_led.direction = Direction.OUTPUT
#blue_led = DigitalInOut(board.D13)
#blue_led.direction = Direction.OUTPUT


Also remove the # sign to uncomment and active those lines

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Re: Lightsaber brightness 3W RGB LED

by axlg on Fri Jul 03, 2020 5:06 pm

caitlinsdad wrote:try change last line
Code: Select all | TOGGLE FULL SIZE
enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = False

to
Code: Select all | TOGGLE FULL SIZE
enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = True


(make sure uppercase "T" - should see it as a keyword your editor)



Hmm this only changed that now the leds start ON.

With "False" leds start off and I need to press the switch to turn them ON.

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by axlg on Fri Jul 03, 2020 6:01 pm

With the led in "white" color, it only draw 14ma. I dont think this is right. Maybe I have damage my board?

Connecting it via usb or the battery. It draw same mA.

With the battery connected directly to the leds with a 10ohm resistor it draw 200mA. So i think the battery and leds are ok

Leds with the board:
20200703_185219.jpg
20200703_185219.jpg (608.36 KiB) Viewed 14 times



Leds with the battery:
20200703_190515.jpg
20200703_190515.jpg (597.57 KiB) Viewed 14 times

axlg
 
Posts: 15
Joined: Thu Aug 23, 2018 5:36 pm

Re: Lightsaber brightness 3W RGB LED

by caitlinsdad on Fri Jul 03, 2020 7:49 pm

I don't know enough about the board or really even the calculations in the code to get the color values to light up the RGB led, maybe the duty_cycle is calculated to a dim range of color/brightness?

You might want to get on the Adafruit Discord app so you can pose your problem there. Hopefully someone who has a similar setup or more electronics knowledge than me can help you out. Good luck.

caitlinsdad
 
Posts: 600
Joined: Fri Feb 24, 2012 4:23 pm

Please be positive and constructive with your questions and comments.