Best way to have Blinkt! display a solid color?

I am trying to set my Blinkt! to display a solid color across all pixels while the Pi is on. i am using the code below, but when i run it, it just flashes once, very quickly and goes off. Am i missing a component that would tell it to stay on until the pi is shut down?

from blinkt import set_pixel, set_brightness, show, clear

set all pixels to RED

for i in range(8):
set_pixel(i, 255, 0, 0)



You can import set_clear_on_exit and use set_clear_on_exit(False) to prevent Blinkt! being cleared when your code exits.

But ideally you need to run a script continuously to display a solid colour, this is because the APA102 LEDs on Blinkt! can very easy interpret environmental noise as signal and display something random.

To do that, you would write something like this:

import time
from blinkt import set_pixel, set_brightness, show, clear


FPS = 15

# set all pixels to RED
while True:
    for i in range(8):
        set_pixel(i, 255, 0, 0)

    time.sleep(1.0 / FPS)

That is really interesting about them interpreting environmental noise. I have been messing with it a lot ,and so far the only successful code i have gotten to work is a reset code that kills whatever it is doing, which is nice for switching between the example scripts they provide. I started with 0 knowledge of any coding language, so it has been a rough start to it. i will try this tonight!

thank you!

Well they’re quite intelligent, and also quite dumb at the same time.

Each pixel understands a sequence of 32 1s and 0s. These are sent by setting a Data pin to either a high voltage (3.3v to equal 1) or low voltage (0v to equal 0). (The actual voltage ranges that are valid for high/low are actually a little more complex than this, but for the sake of simplicity)

The Clock pin is then pulsed, telling the pixel that it’s time to read the next 1 or 0 from the Data line.

Environmental noise can really easily end up coupled into both the Clock/Data line, causing them to appear to be wiggling between 1/0 to the pixels. They then understand this as a valid signal and diligently display the result.

If you poke inside the Blinkt! library, you’ll find it all boils down to just twiddling two GPIO pins.

Try not to get discouraged. I also had zero Python skills before buying my first raspberry Pi. Zero skills in any programing language. It gets easier the more you stick with it. It did for me anyway. You start recognising common errors and stop making them. ;)

My usual approach is to get whatever it is to do something. Doesn’t have to be fancy, just do it reliably. Code that is repeatable and does the same thing every time you run it. Then tweak it to do more. Some of my buds get a chuckle over me because I hardly ever leave my code alone. I’m always trying to add some other functionality.

Anyway, IMHO, if you stick with it, it will eventually become fun, and not so much of a chore. I don’t have Blinkt, not yet anyway. I have a Micro Pixel edge that I’m having fun with though.

I think this will be me. once i get all of them to stay the same i will probably start messing with sequence and all that. I was getting a little discouraged last night, but i think i just needed to get away from it for a second. i will try and get back to it tonight. it has been a decent amount of work just get everything loaded up and stable to get to this point.

blinkt.set_all should set them all to the one color. From here,

blinkt.set_all(255, 0, 0, 0.1) < red with a brightness of 0.1, if I read correctly. 

Click the source link and it takes you here,

I’m the same with Python and Blinkt. I usually forget to use “show()”

I started by playing around with the cpu_temp program in example. I adapted it to show the cpu temperature in binary.

I then tweaked it so that it counts from 0-255. Or displays a decimal number in binary.

Small steps, and test regularly :)