Jump to content

OPI WIN how to steering RGB LED APA106


djmcg

Recommended Posts

Hello

Ones again I need Your advice for steering RGB LED APA106.

I try to search for any program to control this Led but most of them is for RPI and it`s not work for My OPI.

2446293100_1577806970_thumb.jpg

 

Is this connection for DIN should by for any SPI1?:

5420831300_1577806995_thumb.jpg

 

Do You have idea how to for example set change color of led ?

 

Regards

 

 

 

Link to comment
Share on other sites

1 hour ago, djmcg said:

Do You have idea how to for example set change color of led ?

You need some NeoPixel library ...

Here are some info extracted from https://gist.github.com/probonopd/97f6826cc5aa3c0c0950682b0bc266bc

WS2812B Neopixels driven by Python

Connect the data line of the WS2812B Neopixels to pin SPI1_MOSI/PA15. In /boot/armbianEnv.txt we need:

overlays=spi-spidev
param_spidev_spi_bus=1
param_spidev_max_freq=100000000

We can successfully compile the needed Python libraries on the device itself:

git clone https://github.com/doceme/py-spidev.git
cd py-spidev
make -j4
make install
cd ..
git clone https://github.com/joosteto/ws2812-spi.git
find ws2812-spi/ -type f -name '*.py' -exec sed -i -e 's|spi.open(0,0)|spi.open(1,0)|g' {} \;
find ws2812-spi/ -type f -name '*.py' -exec sed -i -e 's|tx=\[\]|tx=\[0x00\]|g' {} \;

Make sure to use spi.open(1,0); we need to use SPI bus 1 since the internal SPI Flash is connected to SPI bus 0.

# Make 16 LEDs red
./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16

# Make 16 LEDs white
./ws2812-spi/ws2812.py -c "[[255,255,255]]" -n 16

# Switch 16 LEDs off
./ws2812-spi/ws2812.py -c "[[0,0,0]]" -n 16

 

Link to comment
Share on other sites

Hello thank for reply:

16 hours ago, martinayotte said:

Connect the data line of the WS2812B Neopixels to pin SPI1_MOSI/PA15

I Have the OPI WIN not Zero so I connect to SPI1_MOSI/PD2 hope it`s good.

 

Next I edit the /boot/armbianEnv.txt file like below :

7226695300_1577872340_thumb.jpg

and saved.

Next steps like You wrote please check:

5631425300_1577872422_thumb.jpg

Unfortunately I have error:

9246514600_1577872514_thumb.jpg

 

Could You advice what I`m doing wrong?

 

 


 

Link to comment
Share on other sites

Hello

I just reinstall Armbian and RGB led start work

However after update

sudo apt install python-numpy

My LED colors is change now off is red and other colors is diffrent

Could You advice why?

?

 

 

 

Link to comment
Share on other sites

I just uninstall python-numpy an color back to normal.

 

I would like to wrote some short code for change colors in python

Could You advice how to implement this

commands for code

On 12/31/2019 at 6:13 PM, martinayotte said:

# Make 16 LEDs red ./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16 # Make 16 LEDs white ./ws2812-spi/ws2812.py -c "[[255,255,255]]" -n 16 # Switch 16 LEDs off ./ws2812-spi/ws2812.py -c "[[0,0,0]]" -n 16

 

Link to comment
Share on other sites

13 hours ago, martinayotte said:

What do you mean ?

Do you mean alternating colors within the same script ?

Simply add sleep command between each calls to ws2812.py ...

Yes I know how to generate colors

But won`t work

I don`t know where to paste this script of different colors.

 

Snap1.jpg

Link to comment
Share on other sites

4 hours ago, djmcg said:

But won`t work

You seems to add calls within the script itself, which is bad technique, resulting to such python error ...

Leave the script unmodified and use a bash script as the master script such as :

 

#!/bin/bash

while true; do
	./ws2812-spi/ws2812.py -c "[[255,0,0]]" -n 16
	sleep 0.5
	./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16
	sleep 0.5
	./ws2812-spi/ws2812.py -c "[[0,0,255]]" -n 16
	sleep 0.5
done

 

Link to comment
Share on other sites

1 hour ago, djmcg said:

I`m really need update script in Python

 

Do You have idea how to update this script for example to kept the same effect what You wrote ?

Then delete all those lines :

    if color!=None:
        write2812(spi, eval(color)*nLED)
    elif doTest:
        test_fixed(spi, nLED)
    else:
        usage()

and add those ones :

    while 1:
        write2812(spi, [[255,0,0])
        time.sleep(0.5)	
        write2812(spi, [[0,255,0])
        time.sleep(0.5)	
        write2812(spi, [[0,0,255])
        time.sleep(0.5)	

Be careful about indentation, python is strict about line alignements ...

Link to comment
Share on other sites

I paste the code what You wrote and perform some updates

 

Unfortunately it`s not work

However

I make some short script like You mentioned before and it`s work but it`s something wrong the RGB LED sometime when should be "off" [(black) (0,0,0)] sometimes shines as RED.

 



 

 

 

Snap4.jpg

Link to comment
Share on other sites

Update code

But nothing chnage 

(however i just lern how to use "" twice  :) Thanks (\" did`t know\" )

import os
import time

White = "/root/Downloads/ws2812-spi/ws2812.py -c \"[[255,255,255]]\" -n 1"
Green = "/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,255,0]]\" -n 1"
Blue =  "/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,0,255]]\" -n 1"
Red = 	"/root/Downloads/ws2812-spi/ws2812.py -c \"[[255,0,0]]\" -n 1"
Off = 	"/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,0,0]]\" -n 1"
y = 0.5

while True:
	
	os.system(White)
	print("white")
	time.sleep(y)
	os.system(Off)
	print("sleep")
	time.sleep(y)
	
	os.system(Blue)
	time.sleep(y)
	os.system(Off)
	time.sleep(y)
	
	os.system(Green)
	time.sleep(y)
	os.system(Off)
	time.sleep(y)

 

Link to comment
Share on other sites

1 hour ago, djmcg said:

It`s any possible to rework that?

I don't know, maybe by lowering the SPI speed ...

Try to change those lines, replacing the 1.05 by 5.05 :

    #print [hex(v) for v in tx]
    spi.xfer(tx, int(4/1.05e-6))
1 hour ago, djmcg said:

any resistor help?

Issue has nothing to do with resistor ...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines