'PICAXE-20M,7 seg LED & DS18B20 demo. Stan.SWAN + PICAXE "Forum" 3 May 2008 'Uses single 7 seg display,sequencing digits so 24°C temp="2" then "4" etc 'Ranges very cold subzero (preceeded with flashing -ve) to ~99°C within ½°C 'Suits further tweaking for info.display needs or enhanced battery life etc '204/256 bytes.Much tighter programming possible- EEPROM,symbol etc 'Program download at => www.picaxe.orconhosting.net.nz/20m7segds.bas 'Schematic download => www.picaxe.orconhosting.net.nz/20m7segds.gif 'Breadboard layout => www.picaxe.orconhosting.net.nz/20m7segds.jpg '--------------------------------------------------------------------------- temp20m:readtemp 7,b0 'DS18B20 temp reading at 20M input 7 if b0>128 then gosub negtemps 'Sub zero temps value correction b1= b0/10 'divide orig temp to get tens value b2= b0//10 'divide orig temp so remainder yields units value if b1=0 then units 'suppress "0" if temps between ±9°C,so "4" & not "04" tens: 'tens numeral test,with first digit suppressed if 0 on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine wait 1:pins=%00000000 'blanks all 7 segs to ensure tens & units pause 200 'don't run together if similar- 11,22,33 etc units: 'units numeral test on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine wait 2 'units digit extra hold on,as likely of most interest pins=%00000000:wait 1 'blanks for DP heartbeat between each temp.display for b3 = 1 to 3:pins=%00000001:wait 1:pins=%00000000:wait 1:next b3 goto temp20m 'Bit order follows 20M outputs 7,6,5,4,3,2,1,0 (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:return '0 shows one: pins=%01100000:return '1 shows two: pins=%10110110:return '2 shows three:pins=%10011110:return '3 shows four: pins=%11001100:return '4 shows five: pins=%11011010:return '5 shows six: pins=%11111010:return '6 shows seven:pins=%00001110:return '7 shows eight:pins=%11111110:return '8 shows nine: pins=%11001110:return '9 shows negtemps:'DS18B20 subzero negative temps routine + flashing -ve alert for b3 = 1 to 2:pins=%10000000:pause 200:pins=%00000000:pause 200:next b3 b0 = b0 - 127:return 'b0 now correctly able to show subzero temps