| Ligne 91 : |
Ligne 91 : |
| | | | |
| | Nous allons pouvoir nous attaquer au reste. | | Nous allons pouvoir nous attaquer au reste. |
| | + | === Installer pySerial, pyFirmata et pip === |
| | + | Installer: |
| | + | * [http://pyserial.sourceforge.net/ pySerial] en utilisant apt-get. |
| | + | * [https://github.com/tino/pyFirmata pyFirmata] en utilisant [http://www.pip-installer.org/en/latest/installing.html pip] |
| | | | |
| − | {{traduction}}
| + | <nowiki>$ sudo apt-get update |
| | + | $ sudo apt-get install python-serial |
| | + | $ sudo pip install pyfirmata</nowiki> |
| | + | |
| | + | === Script de test === |
| | + | |
| | + | Créer le script firmatatest.pu |
| | + | |
| | + | nano firmatatest.py |
| | + | |
| | + | et tapez le script suivant: |
| | + | |
| | + | <nowiki>#!/usr/bin/env python |
| | + | # -*- coding: latin-1 -*- |
| | + | |
| | + | import time |
| | + | import RPi.GPIO as GPIO |
| | + | import pyfirmata |
| | + | GPIO.setmode(GPIO.BOARD) |
| | + | GPIO.setup(12, GPIO.OUT) # GPIO18 (broche 12) en mode sortie (OUTPUT) |
| | + | GPIO.output(12, GPIO.LOW) # GPIO18 LOW (niveau bas) -> désactivé du Reset Arduino |
| | + | # Démarrer la connection avec Arduino UNO |
| | + | # USB: /dev/ttyUSB0 ou /dev/ttyACM0 |
| | + | # UART: /dev/ttyAMA0 |
| | + | board = pyfirmata.Arduino('/dev/ttyUSB0') |
| | + | board.digital[13].write(1) # activer la LED sur la broche 13 |
| | + | time.sleep(3) # delai de 3s |
| | + | board.digital[13].write(0) # Eteindre la LED |
| | + | time.sleep(3) # delai de 3s |
| | + | board.exit()</nowiki> |
| | | | |
| | {{RPI-ShieldBridge-TRAILER}} | | {{RPI-ShieldBridge-TRAILER}} |