Ligne 1 : |
Ligne 1 : |
| == Introduction == | | == Introduction == |
− | Ce tutoriel vous explique comment exploiter comment commander des LEDs (DELs) en utilisant un [http://mchobby.be/PrestaShop/product.php?id_product=160 PI-Cobbler] et Python. | + | Ce tutoriel vous explique comment exploiter comment commander des LEDs (DELs) en utilisant un {{link-product-picobblerplus}} ou {{link-product-picobbler}} et Python.<br /> |
− | Assurez-vous d'avoir [http://mchobby.be/wiki/index.php?title=RaspberryPi-Accueil#Pr.C3.A9paration_pour_Python mis votre environnement Python à jour]. | + | Assurez-vous d'avoir [[RaspberryPi-Accueil#Pr.C3.A9paration_pour_Python|mis votre environnement Python à jour]]. |
| + | |
| + | === Pi-Cobbler ou Pi-Cobbler-Plus? === |
| + | |
| + | {{picobbler-compatibility}} |
| | | |
| == PI Cobbler & resistances == | | == PI Cobbler & resistances == |
Ligne 46 : |
Ligne 50 : |
| On fait ensuite le copier/coller du code | | On fait ensuite le copier/coller du code |
| <nowiki>#!/usr/bin/env python | | <nowiki>#!/usr/bin/env python |
| + | # -*- coding: latin-1 -*- |
| | | |
| import RPi.GPIO as GPIO, time | | import RPi.GPIO as GPIO, time |
Ligne 74 : |
Ligne 79 : |
| GPIO.output(GREEN_LED, False) | | GPIO.output(GREEN_LED, False) |
| GPIO.output(RED_LED, True) | | GPIO.output(RED_LED, True) |
| + | STATE = RED_LED |
| | | |
| time.sleep(LED_PAUSE)</nowiki> | | time.sleep(LED_PAUSE)</nowiki> |
Ligne 79 : |
Ligne 85 : |
| On termine l'opération de saisie simplement avec: | | On termine l'opération de saisie simplement avec: |
| <nowiki>!</nowiki> | | <nowiki>!</nowiki> |
| + | |
| + | === Editer le fichier === |
| + | Si vous aviez besoin de modifier le fichier raspi-blink.py, vous pouvez utiliser nano... rudimentaire mais efficace. |
| + | <nowiki>nano raspi-blink.py</nowiki> |
| + | |
| + | Sachez juste que les options affichée comme '''^X''' signifie '''Ctrl+X''' |
| + | |
| + | === Rendre le fichier exécutable === |
| + | Par défaut, les fichier sont considéré comme des fichiers texte non exécutable... même s'il contiennent des scripts. |
| + | |
| + | Il faut donc indiquer au système d'exploitation qu'il peut autoriser l'exécution de notre raspi-blink.py |
| + | <nowiki>chmod +x raspi-blink.py</nowiki> |
| + | |
| + | == Exécuter notre programme == |
| + | <nowiki>sudo ./raspi-blink.py</nowiki> |
| + | |
| + | == Arrêter votre programme == |
| + | Un simple Ctrl + C fera l'affaire |
| + | |
| + | == Exemple en image == |
| + | {{#Widget:Iframe |
| + | |url=https://www.youtube.com/embed/o6QtrS1o0QY |
| + | |width=420 |
| + | |height=315 |
| + | |border=0 |
| + | }} |
| | | |
| == Ou Acheter == | | == Ou Acheter == |
− | Le [http://mchobby.be/PrestaShop/category.php?id_category=30 Pi-Cobbler est disponible de stock chez MCHobby].
| + | Les produits suivants sont disponibles chez MCHobby: |
| + | * {{link-product-picobblerplus}} |
| + | * {{link-product-pi3}} |
| + | * {{link-product-pi2}} |
| + | * {{link-product-piplus}} |
| + | * {{link-product-picobbler}} |
| + | * {{link-product-pi}} |
| | | |
| {{MCH-Accord}} | | {{MCH-Accord}} |
| | | |
| {{ADF-Accord}} | | {{ADF-Accord}} |