Modifications

Sauter à la navigation Sauter à la recherche
146 octets ajoutés ,  26 mars 2020 à 20:52
Ligne 72 : Ligne 72 :  
Essayez d'exécuter l'instruction ci-dessus en pressant le second bouton (qui porte le numéro 1) PUIS exécutée une seconde fois sans presser le bouton.
 
Essayez d'exécuter l'instruction ci-dessus en pressant le second bouton (qui porte le numéro 1) PUIS exécutée une seconde fois sans presser le bouton.
   −
Vous devriez voir deux résultats différents.
+
Vous devriez voir deux résultats différents comme l'indique la capture ci-dessous.
 +
 
 +
<nowiki>>>> pfd.input_pins[1].value
 +
0
 +
>>> pfd.input_pins[1].value
 +
1
 +
>>></nowiki>
    
=== input_port et output_port ===
 
=== input_port et output_port ===
Ligne 94 : Ligne 100 :     
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
import piface.pfio as pfio
+
import pifaceio as pfio
 
pfio.init()
 
pfio.init()
 
# mettre la sortie 0 a l etat 1 (activer)
 
# mettre la sortie 0 a l etat 1 (activer)
Ligne 105 : Ligne 111 :  
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
from time import sleep
 
from time import sleep
import piface.pfio as pfio
+
import pifaceio as pfio
 
pfio.init()
 
pfio.init()
 
while(True):
 
while(True):
Ligne 118 : Ligne 124 :     
=== Lire une entrée ===
 
=== Lire une entrée ===
Il faut utiliser la fonction {{fname|pfio.digital_read(pin)}} pour lire l'état d'une entrée. La fonction retourne ''1'' si le bouton est pressé (ou entrée activée) sinon elle retourne ''0'' .
+
Il faut utiliser la fonction {{fname|digital_read(pin)}} pour lire l'état d'une entrée. La fonction retourne {{fname|True}} si le bouton est pressé (ou entrée activée) sinon elle retourne '{{fname|False}} .
    
Démarrez un nouvel interpréteur Python et saisissez les instructions suivantes:
 
Démarrez un nouvel interpréteur Python et saisissez les instructions suivantes:
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
import piface.pfio as pfio
+
import pifaceio as pfio
 
pfio.init()
 
pfio.init()
 
# lecture de l entree 0 (correspond au premier bouton)
 
# lecture de l entree 0 (correspond au premier bouton)
Ligne 129 : Ligne 135 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Python affiche ''0''.
+
Python affiche {{fname|False}} .
   −
Maintenez le premier switch enfoncé (celui portant le libellé ''S0'') et saisissez une nouvelle fois la commande {{fname|pfio.digital_read(0)}} .
+
Maintenez le premier switch enfoncé (celui portant le libellé ''S0'') et saisissez une nouvelle fois la commande {{fname|digital_read(0)}} .
   −
Cette fois Python defait afficher ''1''.
+
Cette fois Python devrait afficher {{fname|True}} .
       
{{PiFace2-Manuel-TRAILER}}
 
{{PiFace2-Manuel-TRAILER}}
29 836

modifications

Menu de navigation