sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 439 forks source link

ws2812Led help #172

Closed neofuturism closed 5 years ago

neofuturism commented 5 years ago

Hello, I've been trying to run LEDs (neopixel type) but still can't figure out which pins to use or how to actually trigger them, my code doesn't seem to work at all, can someone direct me on a method to turn them on, Thanks,

`help("modules") from Maix import GPIO from modules import ws2812 from board import board_info

pin = board_info.pin_map(9)# prints only pin 8 information class_ws2812 = ws2812(board_info.D[9],10) r=0 dir = True while True: if dir: r += 1 else: r -= 1 if r>=255: r = 255 dir = False elif r<0: r = 0 dir = True for i in range(30): a = class_ws2812.set_led(i,(r,0,0)) a=class_ws2812.display() `

neofuturism commented 5 years ago

hello, I got it working, power your strips from the 3V port and connect the Data pin to the pin 17: don't forget to include the WS2812 drivers, then run this, I'm sure it's not optimised but it works

help("modules")
import utime
from Maix import GPIO
from modules import ws2812
from board import board_info
from fpioa_manager import fm

pin = board_info.pin_map(17)# prints pin 17
class_ws2812 = ws2812(17,16)
help(utime)
r=0
g=0
b=0
dir = True
while True:
    utime.sleep_ms(20)
    if dir:
        r += 1
        g += 1
        b += 10
    else:
        r -= 1
        g -= 1
        b -= 1
    if r>=255 & g>=255:
        r = 255
        g = 255
        dir = False

    elif r<0 & g<0:
        r = 0
        g = 0
        dir = True

    for i in range(30):
        a = class_ws2812.set_led(i,(r,g,0))
    a=class_ws2812.display()