---
# System prepended metadata

title: W6 0930

---

# W6 0930


## 擴展
```
https://github.com/iCShopMgr/MbitBot.git
```
### snake_01
```python=
y = 0
x = 0
angle = 90
pat = max7219_matrix.get_empty_matrix()
max7219_matrix.setup(1,
    DigitalPin.P16,
    DigitalPin.P15,
    DigitalPin.P14,
    DigitalPin.P13)

def on_forever():
    global x, y, angle
    if angle == 90:
        x = x + 1
    elif angle == 180:
        y = y - 1
    elif angle == 270:
        x = x - 1
    elif angle == 0:
        y = y + 1
    elif angle == 360:
        angle = 0
    max7219_matrix.set_value_in_matrix(pat, x, y, 1)
    max7219_matrix.display_le_ds_for_one(pat, 0)
    basic.pause(500)
basic.forever(on_forever)

```
### MAX7219
```python=
max7219_matrix.setup(1, DigitalPin.P16, DigitalPin.P15, DigitalPin.P14, DigitalPin.P13)
def on_forever():
    max7219_matrix.scroll_text("MAX7219_FirstTest", 50, 200)
    pass
basic.forever(on_forever)

```

### Ws2812作業 - hue順逆時針來回轉

```python=
strip = neopixel.create(DigitalPin.P0, 12, NeoPixelMode.RGB)
h= 0
d= 1 #1= clockwise 0 = counterclockwise
def on_forever():
    global h, d
    strip.show_rainbow(1+h, 360+h)

    if h<= 0 and d== 0:
        d= 1
    elif d== 0:
        h= h-5
    elif h>= 360 and d== 1:
        d= 0
    else:
        h= h+5
    pass

basic.forever(on_forever)
```