
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
> Hello > I use a tastatur 3x4 see part of programm. > It is working but it has also many failures > IsnÂ’t there a stabile program or any hardware to fix this problem? > > Greeting > > Hans > > > #Tijd > print"#CLS#"; > print"#L101#"; > print"Tijd: "; > print HOUR; > print":"; > IF Minute<10 THEN PRINT"0"; > print MINUTE; > print"#L201#"; > PRINT"Goed toets hekje"; > > GOSUB Wacht > > #TijdVerwerking > IF Toets=11 THEN GOTO Datum > IF Toets=4 THEN HOUR=HOUR-1 > IF Toets=1 THEN HOUR=HOUR+1 > IF Toets=5 THEN Minute=Minute-1 > IF Toets=2 THEN Minute=Minute+1 > IF (HOUR<1)or (HOUR>23) THEN HOUR=0 > IF (Minute<1)or(Minute>59)THEN Minute= 0 > GOTO Tijd > > #Datum > print"#CLS#"; > print"#L101#"; > print"Datum "; > IF DAY<10 THEN PRINT"0"; > print DAY; > print"-"; > IF MONTH<10 THEN PRINT"0"; > print MONTH; > PRINT"-20"; > IF YEAR<10 THEN PRINT"0"; > PRINT YEAR; > print"#L201#"; > PRINT"Goed toets hekje"; > > GOSUB Wacht > > #DatumVerwerking > IF Toets=11 THEN GOTO AantalSensors > IF Toets=10 THEN GOTO Tijd > IF Toets=4 THEN DAY=DAY-1 > IF Toets=1 THEN DAY=DAY+1 > IF Toets=5 THEN MONTH=MONTH-1 > IF Toets=2 THEN MONTH=MONTH+1 > IF Toets=6 THEN YEAR=YEAR-1 > IF Toets=3 THEN YEAR=YEAR+1 > IF (DAY<1)or (DAY>31) THEN DAY=1 > IF (MONTH<1)or(MONTH>12)THEN MONTH=1 > IF (YEAR<1)or(YEAR>99)THEN YEAR=0 > GOTO Datum > > #AantalSensors > print"#CLS#"; > print"#L101#"; > print"Aantal sensors "; > PRINT AanTalSens; > print"#L201#"; > PRINT"Goed toets hekje"; > > GOSUB Wacht > > #AantalSensorsVerwerking > IF Toets=11 THEN GOTO Sensor1 > IF Toets=10 THEN GOTO Datum > IF Toets=0 THEN AanTalSens=0 > IF Toets=1 THEN AanTalSens=1 > IF Toets=2 THEN AanTalSens=2 > IF Toets=3 THEN AanTalSens=3 > IF Toets=4 THEN AanTalSens=4 > IF Toets=5 THEN AanTalSens=5 > IF Toets=6 THEN AanTalSens=6 > IF Toets=7 THEN AanTalSens=7 > IF Toets=8 THEN AanTalSens=1 > IF Toets=9 THEN AanTalSens=1 > GOTO AantalSensors > > EnzÂ…Â…Â…Â…Â…Â…Â…Â…Â…Â… > > #Wacht > pause 10 'Wacht hier tot de toets weer wordt los gelaten. > gosub ToetsenBord > if Toets=255 then goto WachtOpToets > goto Wacht > > #WachtOpToets > gosub ToetsenBord > if Toets=255 then goto WachtOpToets > RETURN > > > #ToetsenBord > Toets=255:if ADC8<10 then return > Toets=10:if abs(20-ADC8)<5 then return > Toets=7:if abs(40-ADC8)<5 then return > Toets=4:if abs(58-ADC8)<5 then return > Toets=1:if abs(77-ADC8)<5 then return > Toets=0:if abs(97-ADC8)<5 then return > Toets=8:if abs(115-ADC8)<5 then return > Toets=5:if abs(134-ADC8)<5 then return > Toets=2:if abs(154-ADC8)<5 then return > Toets=11:if abs(173-ADC8)<5 then return > Toets=9:if abs(193-ADC8)<5 then return > Toets=6:if abs(214-ADC8)<5 then return'* > Toets=3:if abs(235-ADC8)<5 then return'# > Toets=255:return Hi Hans, try if this little program runs better on yours. I stored the references in a table. On hardware side I used 12 x 3K3 in the button-chain and 1 x 560K from +5V to the AD-Port for recognizing if no key is pressed. By using other values for the resistors you may have to change the Values in the table. Note that there is only the PRINT command for result output in this example. I took the listing from an old application and it did run well as far as I remember. Best regards, Peter ' --- Definitions -------------------- define Analog AD[8] ' Inputport define Eingabe byte[1] ' Input define Vergleich byte[2] ' reference define Taste byte[3] ' Button define Alt byte[4] ' Old Value define N byte[5] ' Counter ' --- Program Operationen ------ Alt = 0: Taste = 0 #Loop Taste = 0 Eingabe = Analog for N = 0 to 11 looktab Spannungen, N, Vergleich if abs(Eingabe-Vergleich)<3 then Taste=N+1 next if Taste = Alt then goto Loop Alt = Taste if Taste = 0 then goto Loop print Taste-1 goto Loop table Spannungen 152 173 90 0 193 111 23 214 132 46 68 235 tabend |
| Antwort schreiben |