Led python files for 12v leds don't change leds


#1

I am using the Piromoni/blinkt/examples python files for a12v led strip light on my raspberry pi3. The leds are powered by a 12v power supply , and the pi3 is also powered by it’s correct power supply

When I run one of the files, say, solid_colours.py, it seems to run, but the leds don’t change colours or do anything else. With another file, rainbow.py I get this error message:
^CTraceback (most recent call last):
File “rainbow.py”, line 22, in
show()
File “/usr/lib/python2.7/dist-packages/blinkt.py”, line 75, in show
_write_byte(b)
File “/usr/lib/python2.7/dist-packages/blinkt.py”, line 41, in _write_byte
GPIO.output(DAT, byte & 0b10000000)

Then I looked in the blinkt.py it says:
DAT = 23
CLK = 24

What is that referring to, and does DAT mean data pin 23.

My 12v leds are connected to GPIO pins 17, 22 and 24, so do I edit the blinkt.py file and add the led pin numbers.


#2
  • Is the LED strip an APA102 LED strip or something else?
  • If they require 3 pins- 17, 22 and 24 (are those BCM or Physical numbers?) then I suspect they’re not APA102
  • Have you checked the datasheet to see what signal voltage constitutes a HIGH/LOW signal when running at 12v?
  • What protection circuitry are you using between your 12v LEDs and your 3.3v GPIO pins?
  • Are the ground connections for the 12v and 5v power supplies tied to give a common base reference?

Pin numbers in the code are given as BCM- so the Data pin is BCM23 and the Clock pin is BCM24.


#3

No, the LED strip is a cheapo £4.99 one from ebay.

The pin numbers are the GPIO pin numbers on the pi 3, and Red led is on GPIO pin 17, the green pin is on GPIO pin 22, and is on GPIO 24. These would be then BCM 17, BCM 22 and BCM 24.

What data sheet do I look at for the signal voltage.

I have Three N-channel MOSFETs , IRLZ34N for controlling the LEDs, and both grounds are on the same ground or negative rail on the breadboard.

Can I take that there only 2 pins used, BCM23 and BCM24.
The led strip has 1 12v wire and 1 wire for each of the 3 led colours, and they all light up when power is supplied to both the leds and the pi 3


#4

So presumably you’ve got a circuit which - ignoring the resistor that should sit between the LED and voltage supply, and the GPIO pin and the MOSFET - looks something like this for each light channel:

12-leds-gpio

The Blinkt! code assumes a completely different setup for this- it outputs - via clock/data - a protocol which is understood by the embedded circuit in each LED. This embedded circuit then controls the brightness of its LEDs via PWM.

In your case you need to PWM the LEDs directly yourself.

For basic on/off control all you need is something like this:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

my_leds = [17, 22, 24]

GPIO.setup(my_leds, GPIO.OUT, initial=GPIO.LOW)

def turn_on(led):
    GPIO.output(my_leds[led], GPIO.HIGH)

def turn_off(led):
    GPIO.output(my_leds[led], GPIO.LOW)

If you want brightness control you’d have to look into RPi.GPIO’s PWM functionality.


#5

This is how I have it, as per the picture.
The red, green and blue wires are connected from the drain of the mosfet to the led strip.
The red, green and blue wires go from gate of the mosfet to the BCM pins 17, 22 and 24.


#6

What 12v type of led strip is the blinkt python script most suited for.

Mine is 12v and the led measures as 3528 approx, so maybe not suited for the said script