CustomMachine
New Member
I have made up a 3 digit LED display using info from Ron Hackett's Picaxe evil genius book
using the MAX7219 display driver chip
below is some code from Ron's book
I'm using a digital temp sensor and displaying the 2 digit temperature on the first 2 digits
on the 3rd digit I would like to show the letter "c" using segments A,F and G
can anyone please help with this.
using the MAX7219 display driver chip
below is some code from Ron's book
I'm using a digital temp sensor and displaying the 2 digit temperature on the first 2 digits
on the 3rd digit I would like to show the letter "c" using segments A,F and G
can anyone please help with this.
Code:
' === Constants ===
' Hardware interface to the MAX7219
symbol load = C.2 ' briefly pulse C.2 to transfer data to 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 how many digits
symbol on_off = 12 ' 1 = display on; 0 = display off
symbol ones = b2
symbol tens = b3
symbol blank = 15
symbol tempsens = w0 'temperature read from the sensor is stored into vairable w0 called tempsens
' === Directives ===
#com 3 ' specify the com port
#picaxe 20X2 ' specify the PICAXE processor
#no_data ' speed up the download
#no_table ' speed up the download
#terminal off ' disable terminal window
' ============================= Begin Main Program =============================
setfreq m4 'set frequency to 4MHZ
dirsb = %11111111 ' set portB as all outputs
dirsc = %10011111 ' set portC as outputs (except C.6) C.5 is the temp sensor
hspisetup spimode00,spifast ' set up hspi
' Initialize MAX7219
hspiout (scan,2) ' set scan limit for digits 0-3 2 gives us 3 digit display
pulsout load,1
hspiout (brite,2) ' set brightness to 5 (15 = 100%)
pulsout load,1
hspiout (decode,15) ' set BCD decoding for digits 0-3
pulsout load,1
hspiout (on_off,1) ' turn display on
pulsout load,1
temp:
readtemp C.5,tempsens ' read the DS18B20 temperature sensor into vairable w0
'prep the temperature reading into seperate digits
tens = tempsens / 10
ones = tempsens // 10'
if tens = 0 then
tens = blank
endif
' Send data to the four digits
hspiout (1,tens) ' 1st LED from left
pulsout load,1
hspiout (2,ones) ' 2nd LED from left
pulsout load,1
hspiout (3,blank) ' 3rd LED from left
pulsout load,1
pause 500 ' small delay
goto temp ' back to temp