3 devices (7 digit max7219) cascaded with pico w #14052
-
Is there a framework for micropythen to address 3 seperate 8 x 7 segment devices? I read, that the devices can also be controlled separately via an SPI bus, but all the attempts I made didn't work. I'm grateful for every tip |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The picture shows an CS input at the devices. So it looks like you can use a common CLK and DI pin for all of them and have one separate CS pin for each. |
Beta Was this translation helpful? Give feedback.
-
I use this driver: #Connections:
#pico w -> 7 digit device
#
#first device
#GP1, SPI0 CSn -> CS
#GP2, SPI0 SCK -> CLK
#GP3, SPI0 TX -> DIN
#
#second device
#GP5, SPI0 CSn -> CS
#GP2, SPI0 SCK -> CLK
#GP3, SPI0 TX -> DIN
from machine import Pin, SPI
import max7219_8digit
import time
spi0 = SPI(0, baudrate=100000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
ss1 = Pin(1, Pin.OUT)
ss2 = Pin(5, Pin.OUT)
count = 0
line1 = max7219_8digit.Display(spi0, ss1)
line2 = max7219_8digit.Display(spi0, ss2)
while True:
line1.write_to_buffer(str(count))
line1.display()
line2.write_to_buffer(str(count * 2))
line2.display()
count = count + 1
time.sleep(0.5)` And this is the code. But it doesn't run properly. Can you give me an advice? Maybe I did something wrong with the wiring stuff. In the first lines you will find the assignment of the pins. After some correct loops, the second display shows wrong data. But it's not always at the same point when counting up. Display 1 continues to work without any problems! |
Beta Was this translation helpful? Give feedback.
-
Two things. Please see forum guidlines to properly comment code. Basically just surround it with triple quotes. Even though the displays don't use the MISO line you should specify it for SPI to work. It might also help if you showed your errors rather than just stating that it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Looking at your set-up (the picture) I would not completely exclude connection problems (please don't get me wrong, but your soldering looks horrible ...). |
Beta Was this translation helpful? Give feedback.
-
Here is an example that work with two (and more) LED segments in a cascade way. Simply adjust the variable digit= with the correct number (8,16,24,....). Wiring see picture two. hardware pin(2), GP1, SPI0 CSn -> CS import max7219
import time
display = max7219.SevenSegment(digits=16, scan_digits=8, cs=1, spi_bus=0, reverse=True)
display.clear()
display.text("ABCDEFGI12345678")
time.sleep(10)
display.clear()
display.text("22.33 ")
time.sleep(2)
display.clear()
display.message("Hello World")
time.sleep(2)
display.clear() |
Beta Was this translation helpful? Give feedback.
Here is an example that work with two (and more) LED segments in a cascade way. Simply adjust the variable digit= with the correct number (8,16,24,....). Wiring see picture two.
hardware pin(2), GP1, SPI0 CSn -> CS
hardware pin(4), GP2, SPI0 SCK -> CLK
hardware pin(5), GP3, SPI0 TX -> DIN