spi.setup(500000) 'clk on gpio14(d5) mosi on gpio13(d7) load on gpio15(d8)
let load = 15
let digit1 = "01"
let digit2 = "02"
let digit3 = "03"
let digit4 = "04"
let n1 = "1"
let n2 = "2"
let n3 = "3"
let n4 = "4"
let count = 0
io(po,load,0)'set load pin low
print "Max7219 test program"
print
textbox n1
textbox n2
textbox n3
textbox n4
wprint "<br>"
print "Each box corresponds to a digit on the display. Valid inputs are 0-9 and a-f."
'initialize max7219
spi.hex("090F",2) 'decode address 0x0F code b for digits 0->3.
io(po,load,1) 'pulse load to latch data
delay 50
io(po,load,0)
spi.hex("0B03",2) 'scan limit address 0x03 enable digits 0->3.
io(po,load,1)
delay 50
io(po,load,0)
spi.hex("0A08",2) 'intensity address 0x08 medium intensity.
io(po,load,1)
delay 50
io(po,load,0)
spi.hex("0C01",2) 'power on. 01 for on 00 for off.
io(po,load,1)
delay 50
io(po,load,0)
spi.hex("0F00",2) 'test off. 01 for on 00 for off.
io(po,load,1)
delay 50
io(po,load,0)
'refresh display values once a second
timer 1000, [write7219]
wait
[write7219]
spi.hex(digit1 & n1,2)
io(po,load,1)
delay 50
io(po,load,0)
spi.hex(digit2 & n2,2)
io(po,load,1)
delay 50
io(po,load,0)
spi.hex(digit3 & n3,2)
io(po,load,1)
delay 50
io(po,load,0)
spi.hex(digit4 & n4,2)
io(po,load,1)
delay 50
io(po,load,0)
wait
Moderator: Mmiscool
http://esp8266basic.com
A BASIC interpreter for your ESP
Working now on Autodrop3d. A 3d printer with automatic part ejection system. https://autodrop3d.com