Hi,
I am trying to drive 4 seven segment displays (7") with a MAX7219 from a 20M2. I can get the first segment to show a 'H' but the others will not switch on. Via PICAXE VSM (great program) I can see that they are getting the data, just not being switched on. I am using the C.0 to drive another two segments and would like not to use C.0. DO I need to be using the hserout or can I use the three that I have listed? This code is not mine but it will be easy for me (almost training wheels off) to be able to use it to get the four segments to count down minutes. This is my final goal.
I have four Comon Cathodes so I want to use them and not have to buy CA's.
Thanks
Jaden
I am trying to drive 4 seven segment displays (7") with a MAX7219 from a 20M2. I can get the first segment to show a 'H' but the others will not switch on. Via PICAXE VSM (great program) I can see that they are getting the data, just not being switched on. I am using the C.0 to drive another two segments and would like not to use C.0. DO I need to be using the hserout or can I use the three that I have listed? This code is not mine but it will be easy for me (almost training wheels off) to be able to use it to get the four segments to count down minutes. This is my final goal.
I have four Comon Cathodes so I want to use them and not have to buy CA's.
Thanks
Jaden
Code:
' ================================== MAX7219_Countdown.bas =================================
' This program uses a PICAXE-20M2 to manually shift-out SPI data to
' a MAX7219 LED display driver. The 7219 is connected to a 4-digit,
' 7-segment LED display. The program displays the word "HELP"
' === Constants ===
' Hardware interface to the MAX7219
symbol sData = B.5 ' data out line to Max7219
symbol clock = B.7 ' clock line
symbol sLoad = B.6 ' pulse briefly to load data onto LEDs
' Register addresses for the MAX7219
symbol decode = 9 ' decode register; specify digits to decode
symbol brite = 10 ' intensity (brightness) register; 15 = 100%
symbol scan = 11 ' scan-limit register; specify # of LEDs
symbol on_off = 12 ' 1 = display on; 0 = display off
' === Variables =====
symbol outByte = b0 ' data byte to be transmitted to the LED
symbol maxReg = b1 ' MAX register that receives the data byte
symbol forMax = w0 '
symbol index = b2 ' used in for-next loop
' === Directives ====
#picaxe 20M2 ' specify PICAXE processor
' ============================== Begin Main Program =============================
' Initialize MAX7219
maxReg = scan ' set scan limit for digits 0-3
outByte = 3
gosub shout16
maxReg = brite ' set brightness to 5 (15 = 100%)
outByte = 5
gosub shout16
maxReg = decode ' set BCD decoding for digits 0-3
outByte = 15
gosub shout16
maxReg = on_off ' turn display on
outByte = 1
gosub shout16
' Send data to the four digits
maxReg = 1 ' 1st LED from left = "H"
outByte = 12
gosub shout16
maxReg = 2 ' 2nd LED from left = "E"
outByte = 11
gosub shout16
maxReg = 3 ' 3rd LED from left = "L"
outByte = 13
gosub shout16
maxReg = 4 ' 4th LED from left = "P"
outByte = 14
gosub shout16
end
' ==================== End Main Program - Subroutines follow =====================
shout16:
for index = 15 to 0 step -1 ' MAX7219 requires a 16-bit word
if bit15 = 1 then ' set sdata to correspond to bit15
high sData
else
low sData
endif
pulsout clock, 2 ' briefly pulse the clock line
forMax = forMax * 2 ' shift char left for next MSB
next index
pulsout sLoad,2 'briefly pulse the load line
return