5 ' --- Gradateur 2 voies --- 10 const device = 3B 20 lcdinit : csroff 30 dim PU1 as integer : dim PG1 as integer : dim PU2 as integer : dim PG2 as integer : dim AD as byte : dim RT as byte : dim V as byte 31 dim ECO1 as integer : dim ECO2 as integer : dim PU1D as integer : dim PU2D as integer : dim PG1D as integer : dim PG2D as integer 32 dim TECO1 as byte : dim TECO2 as byte : dim F as byte 33 PU1 = 1000 : PG1 = 0 : PU2 = 1000 : PG2 = 0 35 cls : locate 0,0 : print "** Gradateur ** " : locate 0,1 : print "(c) ELEKTOR 2008" 40 ' --- Configuration de la voie 1 --- 41 sound 6,159,4 : delay 5000 50 cls 60 locate 0,0 : print "PN Recepteur 1 ?" : locate 0,1 : print "PN voie 1 :";dec(PU1);" W" : sound 6,159,4 65 AD = KEYIN (0,15) : RT = KEYIN (1,15) : V = KEYIN (2,15) 70 if AD = 1 and RT = 1 and V = 1 then goto 65 71 if AD = 0 and PU1 < 1840 then PU1 = PU1 + 10 72 if RT = 0 and PU1 > 10 then PU1 = PU1 - 10 75 locate 0,1 : print "PN voie 1 :";dec(PU1): csroff 76 delay 50 : sound 6,139,1 78 if V = 0 THEN GOTO 80 79 goto 65 80 cls : PG1 = PU1 / 2 90 locate 0,0 : print "PG Gradateur 1 ?" : locate 0,1 : print "PG voie 1 :";dec(PG1); " W" : sound 6,159,4 95 AD = KEYIN (0,15) : RT = KEYIN (1,15) : V = KEYIN (2,15) 100 if AD = 1 and RT = 1 and V = 1 then goto 95 101 if AD = 0 and PG1 < PU1 then PG1 = PG1 + 10 102 if RT = 0 and PG1 > 10 then PG1 = PG1 - 10 105 locate 0,1 : print "PG voie 1 :";dec(PG1): csroff 106 delay 50 : sound 6,139,1 108 if V = 0 AND PU1 >= PG1 THEN GOTO 120 109 goto 95 120 cls : locate 0,0 : print "PN1 = "; dec(PU1);" W": locate 0,1 : print "PG1 = "; dec(PG1);" W" : csroff 140 ' --- Configuration de la voie 2 --- 141 sound 6, 159 , 4 : delay 5000 150 cls 160 locate 0,0 : print "PN Recepteur 2 ?" : locate 0,1 : print "PN voie 2 :";dec(PU2);" W" : sound 6,159,4 165 AD = KEYIN (0,15) : RT = KEYIN (1,15) : V = KEYIN (2,15) 170 if AD = 1 and RT = 1 and V = 1 then goto 165 171 if AD = 0 and PU2 < 1840 then PU2 = PU2 + 10 172 if RT = 0 and PU2 > 10 then PU2 = PU2 - 10 175 locate 0,1 : print "PN voie 2 :";dec(PU2) : csroff 176 delay 50 : sound 6,139,1 178 if V = 0 THEN GOTO 180 179 goto 165 180 cls : PG2 = PU2 / 2 190 locate 0,0 : print "PG Gradateur 2 ?" : locate 0,1 : print "PG voie 2 :";dec(PG2);" W" : sound 6,159,4 195 AD = KEYIN (0,15) : RT = KEYIN (1,15) : V = KEYIN (2,15) 200 if AD = 1 and RT = 1 and V = 1 then goto 195 201 if AD = 0 and PG2 < PU2 then PG2 = PG2 + 10 202 if RT = 0 and PG2 > 10 then PG2 = PG2 - 10 205 locate 0,1 : print "PG voie 2 :"; dec(PG2): csroff 206 delay 50 : sound 6,139,1 208 if V = 0 AND PU2 >= PG2 THEN GOTO 220 209 goto 195 220 cls : locate 0,0 : print "PN2 = "; dec(PU2);" W": locate 0,1 : print "PG2 = "; dec(PG2);" W" : csroff 230 ' --- Affichage des économies envisagées --- 240 delay 3000 : sound 6,159,4 250 cls : locate 0,0 : print "Economies" : locate 0,1 : print "prevues (%) :" : csroff 260 PG1D = (PG1 / 10) : PU1D = (PU1 / 10) 265 ECO1 = ( 100 * PG1D ) / PU1D 266 TECO1 = (100 - ECO1) 270 PG2D = (PG2 / 10) : PU2D = (PU2 / 10) 275 ECO2 = ( 100 * PG2D ) / PU2D 276 TECO2 = (100 - ECO2) 280 delay 2000 : sound 6,159,4 : cls 290 cls : locate 0,0 : print "Voie 1 :";dec(TECO1);" %" : locate 0,1 : print "Voie 2 :";dec(TECO2);" %" : csroff 300 ' --- Fonctionnement des sorties 310 for F = 1 TO 100 320 if F > TECO1 then OUT 12,1 else OUT 12,0 330 if F > TECO2 THEN OUT 14,1 else OUT 14,0 340 delay 50 350 next F 360 V = KEYIN (2,15) 370 IF V = 0 then goto 5 380 cls : locate 0,0 : print "** Gradateur ** " : locate 0,1 : print "(c) ELEKTOR 2008" 390 for F = 1 TO 100 400 if F > TECO1 then OUT 12,1 else OUT 12,0 410 if F > TECO2 THEN OUT 14,1 else OUT 14,0 420 delay 50 430 next F 440 V = KEYIN (2,15) 450 IF V = 0 then goto 5 460 goto 290