Ligne 49 : |
Ligne 49 : |
| | | |
| # Bouche infinie qui change l'état de la LED (allumé/éteind) et lit l'état de l'entrée. | | # Bouche infinie qui change l'état de la LED (allumé/éteind) et lit l'état de l'entrée. |
| + | # Presser Ctrl-C pour quitter le programme |
| print 'Press Ctrl-C to quit.' | | print 'Press Ctrl-C to quit.' |
| while True: | | while True: |
− | # Set pin C0 to a high level so the LED turns on. | + | # Mettre la broche C0 au niveau haut (HIGH) pour allumer la LED. |
| ft232h.output(8, GPIO.HIGH) | | ft232h.output(8, GPIO.HIGH) |
− | # Sleep for 1 second. | + | # Attendre 1 seconde. |
| time.sleep(1) | | time.sleep(1) |
− | # Set pin C0 to a low level so the LED turns off. | + | # Mettre la broche C0 au niveau base (LOW) pour eteindre la LED. |
| ft232h.output(8, GPIO.LOW) | | ft232h.output(8, GPIO.LOW) |
− | # Sleep for 1 second. | + | # Attendre 1 seconde. |
| time.sleep(1) | | time.sleep(1) |
− | # Read the input on pin D7 and print out if it's high or low. | + | # Lire l'etat de la broche D7 et afficher si le niveau est haut (HIGH) ou bas (LOW). |
| level = ft232h.input(7) | | level = ft232h.input(7) |
| if level == GPIO.LOW: | | if level == GPIO.LOW: |
Ligne 67 : |
Ligne 68 : |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | Save the file and then open a command line terminal and navigate to the folder with gpio_test.py. Run the script by executing on Windows:
| + | Sauvez le fichier puis ouvrez un terminal de commande. |
| + | |
| + | Utilisez la commande {{fname|cd}} pour vous rendre dans le répertoire où le fichier '''gpio_test.py''' est stocké. |
| + | |
| + | Exécutez le script en exécutant la commande suivante sous Windows: |
| | | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
Ligne 73 : |
Ligne 78 : |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | Or on Mac OSX or Linux run the script as root by executing:
| + | Ou la commande suivante sous Mac OSX ou Linux (nous utilisons {{fname|sudo}} pour avoir les droits administrateurs): |
| | | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
Ligne 79 : |
Ligne 84 : |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | You should see the LED start to blink once a second, and the state of the D7 input is also printed. For example if D7 is connected to ground you'll see:
| + | Vous devriez voir la LED commencer à clignoter une fois par seconde et afficher régulièrement l'état de la broche D7. |
| + | |
| + | Par exemple, si la broche D7 est connectés sur la masse, vous devriez voir: |
| | | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
Ligne 87 : |
Ligne 94 : |
| Pin D7 is LOW! | | Pin D7 is LOW! |
| </syntaxhighlight> | | </syntaxhighlight> |
| + | |
| + | {{traduction}} |
| | | |
| Try moving the jumper wire for D7 from ground to 5 volts. You should see the input start to read a high value: | | Try moving the jumper wire for D7 from ground to 5 volts. You should see the input start to read a high value: |