5 ' --- Thermometre numérique multi-unités --- 10 const device = 3B 15 lcdinit : cls 20 ' --- Déclaration des variables utilisées --- 21 dim U as integer : dim TMK as integer : dim TMC as byte : dim TMF as byte : dim BP as byte : dim R as integer 22 dim TMKMIN as integer : dim TMKMAX as integer : dim TMKMOY as integer : dim N as byte : dim T as integer 23 dim TMKMINP as integer : dim TMKMAXP as integer : dim TMKMOYP as integer 24 dim TMCMIN as byte : dim TMCMAX as byte : dim TMCMOY as byte 25 ' --- Initialisation des variables --- 26 U = 0 : TMK = 0 : TMC = 0 : TMF = 0 : TMKMAX = 0 : TMKMIN = 0 : TMKMOY = 0 : TMKMOYP = 0 27 ' --- Affichage message d'accueil --- 28 cls : locate 0,1 : print "* Thermometre * " : locate 0,2 : print "(c) ELEKTOR 2008" : csroff : delay 5000 : cls 35 ' --- Programme principal --- 40 ' --- Mesure de la température relevée par le capteur LM 335 --- 41 U = ADIN(0) : TMK = (90*U)/184 42 ' --- Initialisation des variables suite à la première mesure -- 43 TMKMAX = TMK 44 TMKMIN = TMK 49 for N = 1 to 180 50 U = ADIN(0) : TMK = (90*U)/184 55 if TMK > TMKMAX then TMKMAX = TMK 60 if TMK < TMKMIN then TMKMIN = TMK 70 TMKMOY = (((N-1)*TMKMOYP)+TMK)/N 75 TMKMOYP = TMKMOY 80 if TMK > 272 then gosub 2000 85 if TMK < 273 then gosub 2500 86 if TMK > 255 then gosub 3000 87 if TMK < 256 then gosub 3500 88 out 8,1 : delay 200 : out 8,0 : gosub 1000 89 cls : locate 0,0 : print "Mesures (3 h) : " 90 if TMKMAX > 272 then gosub 4000 95 if TMKMAX < 273 then gosub 5000 100 if TMKMIN > 272 then gosub 6000 105 if TMKMIN < 273 then gosub 7000 110 if TMKMOY > 272 then gosub 8000 115 if TMKMOY < 273 then gosub 9000 120 out 8,1 : delay 200 : out 8,0 : gosub 1000 150 next N 200 goto 25 1000 ' --- Temporisation 30 secondes --- 1010 for T = 1 to 300 1020 BP = keyin (2,25) 1030 if BP = 0 then goto 20 1040 delay 100 1050 next T 1060 return 2000 ' --- Gestion affichage température °C positive --- 2010 cls : locate 0,0 : print "Temperatures : " 2020 TMC = (TMK - 273) 2030 locate 0,1 : print dec(TMC);" deg.C" 2040 locate 0,2 : print dec(TMK);" K" 2050 return 2500 ' --- Gestion affichage température °C négative --- 2510 cls : locate 0,0 : print "Temperatures : " 2520 TMC = (273 - TMK) 2530 locate 0,1 : print "-";dec(TMC);" deg.C" 2540 locate 0,2 : print dec(TMK);" K" 2550 return 3000 ' --- Gestion affichage température °F positive --- 3010 TMF = (((18*TMK) - 4597)/10) 3020 locate 0,3 : print dec(TMF);" deg.F" 3030 return 3500 ' --- Gestion affichage température °F négative --- 3510 R = (18*TMK) : TMF = (4597 - R) / 10 3520 locate 0,3 : print "-";dec(TMF);" deg.F" 3530 return 4000 ' --- Gestion affichage Tmax °C positive --- 4010 TMCMAX = TMKMAX - 273 4020 locate 0,1 : print "Tmax";dec(TMCMAX);" dg.C" 4030 return 5000 ' --- Gestion affichage Tmax °C négative --- 5010 TMCMAX = 273 - TMKMAX 5020 locate 0,1 : print "Tmax -";dec(TMCMAX);" dg.C" 5030 return 6000 ' --- Gestion affichage Tmin °C positive --- 6010 TMCMIN = TMKMIN - 273 6020 locate 0,2 : print "Tmin";dec(TMCMIN);" dg.C" 6030 return 7000 ' --- Gestion affichage Tmin °C négative --- 7010 TMCMIN = 273 - TMKMIN 7020 locate 0,2 : print "Tmin -";dec(TMCMIN);" dg.C" 7030 return 8000 ' --- Gestion affichage Tmoy °C positive --- 8010 TMCMOY = TMKMOY - 273 8020 locate 0,3 : print "Tmoy";dec(TMCMOY);" dg.C" 8030 return 9000 ' --- Gestion affichage Tmoy °C négative --- 9010 TMCMOY = 273 - TMKMOY 9020 locate 0,3 : print "Tmoy -";dec(TMCMOY);" dg.C" 9030 return