# -------------------------------------------------- #
# This file is autogenerated by pioasm; do not edit! #
# -------------------------------------------------- #
import utime
import rp2
import max7219
from rp2 import PIO
from machine import Pin, SPI
from time import sleep
state = False;
data = 3; # pin connected to the serial input of the MAX7219 (DIN)
load = 5; # pin for loading data (CS)
clk = 2; # pin for the clock of the serial link (CLK)
spi = SPI(0, sck=Pin(clk), mosi=Pin(data))
cs = Pin(load, Pin.OUT)
display = max7219.Matrix8x8(spi, cs, 3)
display.brightness(10);
led0 = Pin(28, Pin.OUT)
led0.off()
led1 = Pin(27, Pin.OUT)
led1.off()
led2 = Pin(26, Pin.OUT)
led2.off()
led3 = Pin(22, Pin.OUT)
led3.off()
leds = [led0, led1, led2, led3]
button = Pin(6, Pin.IN, Pin.PULL_UP)
def setLEDs(value):
for led in leds:
led.value(value)
utime.sleep(0.25)
while True:
display.fill(0)
display.pixel(0,0,9);
display.pixel(1,0,9);
display.show()
if button.value() != 1:
if state == False:
print("Power On")
state = True
else:
print("Power Off")
state = False
if state == True :
print("Blink On")
setLEDs(1);
print("Blink Off")
setLEDs(0)
else:
utime.sleep(1)
for led in leds:
led.value(0)