20M +7 seg +DS18B20 =easy! I'm surprised we haven't had a run of such circuits already.
Code:
'PICAXE-20M with 7 seg & DS18B20 workout. Stan. SWAN 30/4/08
'Just a single 7 seg display,but numbers sequenced so 24= "2" then "4" etc
'Works VERY well,but 20M allows only 16 gosubs,so max.temp 59 C & no subzero!
temp20m:
readtemp 7,b0
b1= b0/10 'divide orig temp to get tens value
b2= b0//10 'divide orig temp so remainder yields units value
if b1=1 then gosub one 'tens numeral test,with <10C 1st numeral supressed
if b1=2 then gosub two
if b1=3 then gosub three
if b1=4 then gosub four
if b1=5 then gosub five
pins=%00000000 'briefly blank all 7 segs to ensure tens & units
pause 200 'don't run together if similar- 11,22,33 etc
if b2=0 then gosub zero 'units numeral test
if b2=1 then gosub one
if b2=2 then gosub two
if b2=3 then gosub three
if b2=4 then gosub four
if b2=5 then gosub five
if b2=6 then gosub six
if b2=7 then gosub seven
if b2=8 then gosub eight
if b2=9 then gosub nine
wait 1 '1 sec.hold on units digit(likely of most interest)
pins=%00000000 'briefly blank all 7 segs to ensure display order
wait 1 '& temp. reading distinctive
goto temp20m 'repeat DS18B20 temp.reading routine
'Bit order follows 20M outputs 76543210 (or 7 seg g,f,e,d,c,b,a,+DP)
'if wired as on 20M breadboard demo using DSE Z4104 7 seg LED
zero: pins=%01111110:pause 500:return '0 shows
one: pins=%01100000:pause 500:return '1 shows
two: pins=%10110110:pause 500:return '2 shows
three:pins=%10011110:pause 500:return '3 shows
four: pins=%11001100:pause 500:return '4 shows
five: pins=%11011010:pause 500:return '5 shows
six: pins=%11111000:pause 500:return '6 shows
seven:pins=%00001110:pause 500:return '7 shows
eight:pins=%11111110:pause 500:return '8 shows
nine: pins=%11001110:pause 500:return '9 shows
Attachments
-
141.3 KB Views: 178
Last edited: