BonjourPiem, toujours aux aguets !
Je suis tombé sur ton clavier " analogique", solution très originale pour n'utiliser qu'une seule entrée !
Voilà le programme :
symbol line1=B.2 ;pin11
symbol line2=B.3 ;pin10
symbol line3=B.4 ;pin9
symbol line4=B.5 ;pin8
symbol display=B.1 ;pin12
symbol touche=bit1
symbol ligne= b1
symbol valeur=b2
symbol compteur=b3
symbol somme=w2
Main: ;
pause 1000 ; for display
serout display,N2400,(254,1)
valeur=1
compteur=0
setint %00000000,%00000010 ;enable interrupt for pin7 (C.0)when low, sw GO
Scan_keypad:
for ligne=2 to 5 ;sélection directe de la ligne, de B.2 ? B.5
high ligne ;ligne correspondante high
If pinC.3=1 then ;col 1 pin5
do
loop until pinC.3=0
touche=1 ;indique qu'une touche a été pressée
goto Nextnumber
else
inc valeur
endif
if PinC.2=1 then ;col 2 pin6
do
loop until pinC.2=0
touche=1
goto Nextnumber
else
inc valeur
endif
if PinC.0=1 Then ;col 3 pin7
do
loop until pinC.0=0
touche=1
goto Nextnumber
else
inc valeur
End if
low ligne
Next ligne ;
Nextnumber:
if touche=0 then ;pas de rentrée de chiffre, retour au scan
valeur=1
goto Scan_keypad
endif
touche=0
inc compteur
if valeur=11 then ;pour valeur = 0
valeur=0
endif
serout display,N2400,(254,128,#valeur)
pause 1000
serout display,N2400,(254,1)
Store_value:
if compteur=1 then ;recombinaison des chiffres
b10=valeur
somme=b10
elseif compteur=2 then
b11=valeur
somme=somme*10+b11 ;déplacement du 1° chiffre a gauche
elseif compteur=3 then
b12=valeur
somme=somme*10+b12
elseif compteur=4 then
b13=valeur
somme=somme*10+b13
endif
goto Scan_keypad
Moving:
pause 10
serout display,N2400,(254,192,"somme=",#somme,"");
pause 5000
goto main
interrupt: ; switch GO depressed
do
loop until pinC.1=1
setint %00000000,%00000010 ; re-initialise l'interrupt
goto Moving
return