Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OPI WIN how to steering RGB LED APA106

Featured Replies

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

 

 

 

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

 

  • Author

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?

 

 


 

  • Author

The system image: https://dl.armbian.com/_old/orangepiwin/archive/Armbian_19.11.4_Orangepiwin_bionic_current_5.3.13_desktop.img.gz

Now I have problem with connection to internet :(

  • Author

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?

?

 

 

 

  • Author

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

 

  • Author
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

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

 

  • Author

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 ?

 

 

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 ...

  • Author

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

  • Author

Update, something work but colors is different that should be :(

 

back to you first script please check the video the colors is diifren than code (RED is note in Code)

 

 

 


 

Snap70.jpg

  • Author

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)

 

  • Author
20 hours ago, martinayotte said:

If you only send [0,0,0] frequently, does it becomes RED sometimes ?

 

Yes.

It`s any possible to rework that? any resistor help?

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 ...

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.