5 ' --- Capacimètre numérique --- 10 const device = 3B 15 lcdinit : cls : csroff : out 2,1 : out 3,1 20 ' --- Déclaration des variables utilisées --- 21 dim S1 as byte : dim VAD0 as integer : dim VAD1 as integer : dim VAD4 as integer : dim N as integer : dim C as integer : dim F as byte : dim NUM as integer : dim DEM as integer : dim RES as integer 30 ' --- Affichage du message d'accueil --- 31 locate 0,0 : print "* Capacimetre *" : locate 0,1 : print "(c) ELEKTOR 2008" 32 sound 7,159,4 : delay 5000 40 ' --- Initialisation mesure --- 45 cls : locate 0,0 : print "Raccordez un " : locate 0,1 : print "condensateur ..." 46 for F = 1 to 100 47 S1 = keyin (10,25) 48 if S1 = 0 then goto 100 49 next F 55 cls : locate 0,0 : print "... puis appuyez" : locate 0,1 : print "sur le bp . " 56 for F = 1 to 100 57 S1 = keyin (10,25) 58 if S1 = 0 then goto 100 59 next F 65 goto 45 100 ' --- Mesures des tensions VAD0 et VAD1 --- 102 out 11,1 : delay 100 105 out 2,0 : VAD1 = ADIN(1) : delay 1 : out 2,1 : delay 10 110 out 3,0 : VAD0 = ADIN(0) : delay 1 : out 3,1 : delay 10 115 out 11,0 120 VAD4 = ADIN(4) 130 if VAD4 > 0 then gosub 2000 200 ' --- Mesure C en nF --- 205 cls : locate 0,0 : print "Mesure en cours " 210 for N = 1 to 1400 220 out 2,0 : delay 1 : out 2,1 230 VAD4 = ADIN(4) 231 NUM = (VAD4 / 2) * 100 : DEM = VAD1 / 2 : RES = NUM / DEM 240 if RES >= 95 then goto 300 250 next N 260 goto 400 300 ' --- Affichage valeur de C en nF --- 310 if N >= 650 then C = (N / 14) * 100 311 if N < 650 then C = (100 * N) / 14 315 cls : locate 0,0 : print "Resultat : " 320 locate 0,1 : print " C = ";dec(C);" nF" 330 sound 7,159,4 : goto 800 400 ' --- Mesure C en micro-F --- 410 VAD4 = ADIN (4) 420 if VAD4 > 0 then gosub 2000 430 cls : locate 0,0 : print "Mesure en cours " 440 for N = 1 to 14000 450 out 3,0 : delay 1 : out 3,1 460 VAD4 = ADIN(4) 461 NUM = (VAD4 / 2) * 100 : DEM = VAD0 / 2 : RES = NUM / DEM 470 if RES >= 95 then goto 500 480 next N 490 goto 900 500 ' --- Affichage valeur de C en micro-F --- 505 gosub 1000 510 if N >= 6500 then C = (N / 14) * 10 520 if N < 6500 then C = (10 * N) / 14 530 cls : locate 0,0 : print "Resultat : " 540 locate 0,1 : print " C = ";dec(C);" ";8;"F" 550 sound 7,159,4 : goto 800 800 ' --- Nouvelle mesure --- 810 delay 5000 815 cls : locate 0,0 : print "Nouvelle mesure " : sound 7,159,4 : delay 3000 820 cls : locate 0,0 : print "Raccordez un " : locate 0,1 : print "condensateur ..." 825 for F = 1 to 100 830 S1 = keyin (10,25) 835 if S1 = 0 then goto 880 840 next F 845 cls : locate 0,0 : print "... puis appuyez" : locate 0,1 : print "sur le bp . " 850 for F = 1 to 100 855 S1 = keyin (10,25) 860 if S1 = 0 then goto 880 865 next F 870 goto 820 880 VAD4 = ADIN(4) : if VAD4 > 0 then gosub 2000 890 goto 200 900 ' --- Mesure impossible --- 910 cls : locate 5,0 : print "Mesure" : locate 2,1 : print "IMPOSSIBLE !" : sound 7,255,32 920 delay 3000 : gosub 1000 930 cls : locate 0,0 : print " C > 10000 ";8;"F" 940 goto 800 1000 ' --- SP Création de la lettre grecque "mu" --- 1010 busout &HA5,8,&H11,&H11,&H11,&H1E,&H10,&H10,&H10,&H10 1020 return 2000 ' --- SP Décharge du condensateur (1s)--- 2010 cls : locate 0,0 : print "Decharge du " : locate 0,1 : print "condensateur " 2020 out 11,1 : delay 1000 : out 11,0 2030 return