# Single 8x8 LED Matrix
# https://microcontrollerslab.com/max7219-led-dot-matrix-display-raspberry-pi-pico/
# http://docs.micropython.org/en/latest/library/framebuf.html
# Cables
# Matrix1:V+ - Pico:3V3 - Red
# Matrix1:GND - Pico:GND.1 - Black
# Matrix1:DIN - Pico:GP3 - Orange
# Matrix1:CS - Pico:GP5 - Purple
# Matrix1:CLK - Pico:GP2 - Green
from machine import Pin, SPI
from time import sleep
import max7219
spi = SPI(0, phase=0, sck=Pin(2), mosi=Pin(3))
cs = Pin(5, Pin.OUT)
display = max7219.Matrix8x8(spi, cs, 1)
display.brightness(10)
while True:
display.pixel(1,1,1)
display.pixel(1,2,1)
display.pixel(1,3,1)
display.pixel(1,4,1)
display.pixel(2,1,1)
display.pixel(3,1,1)
display.pixel(4,1,1)
display.show()
sleep(0.1)
# options
#display.pixel(1,1,1) # display.pixel(x,y,On(1) or Off(0))
#display.fill(1) # fills whole screen On or Off (0).
#display.text('1',0,0,1) # Displays the Number 1 on the screen from the coords given.
#display.hline(0,0,8,1) #horizontal line
#display.vline(0,0,8,1) #vertical line
#display.line(0,0,4,1) # Draw a line from a set of coordinates using the given color and a thickness of 1 pixel.
#display.rect(0,0,8,8,1) #.rect(x, y, w, h, c)
#display.fill_rect(1, 1, 6, 6, 1) #fill_rect(x, y, w, h, c)
# Challenge - Can you add further screens to make a bigger picture?
# Can you make text scroll?
# can you make an animation?