PHP appel d'un script python
Bonjour � tous
Je tiens � pr�ciser que j'ai pas mal cherch� avant de venir ici, mais je bloque un peu (beaucoup)
Mon but : me cr�er un petit robot qui tourne avec un raspberry sous linux (raspbian)
Mais j'y vais pas � pas, car sur le net, tout plein de page sont d�di�e � la robotique et domotique, mais rien de suffisamment bien d�taill� et surtout expliqu�
Pour clarifier un max, je vais simplifier mon projet :
J'ai une led que je voudrais allumer ou �teindre et tout �a en passant par un fichier qui est �crit en python que je voudrai appeler d'une page internet
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import smbus
import time
#bus = smbus.SMBus(1) # Rev 2 Pi uses 1
DEVICE = 0x20 # Device address (A0-A2)
IODIRA = 0x00 # Pin direction register
OLATA = 0x14 # Register for outputs
GPIOA = 0x12 # Register for inputs
# Set all GPA pins as outputs by setting
# all bits of IODIRA register to 0
bus.write_byte_data(DEVICE,IODIRA,0x00)
# Set output all 7 output bits to 0
bus.write_byte_data(DEVICE,OLATA,0)
for MyData in range(1,4):
# Count from 1 to 8 which in binary will count
# from 001 to 111
bus.write_byte_data(DEVICE,OLATA,MyData)
print MyData
time.sleep(1)
# Set all bits to zero
bus.write_byte_data(DEVICE,OLATA,0) |
ce code en python permet de compter avec deux led en binaire (00, 01, 10, 11), en passsant par un MCP23017 (qui permet lui m�me d'ajouter 17 ports au GPIO du raspberry)
Ce code fonctionne en passant par la commande
Code:
sudo python allumage.py
autre moyen d'allumer juste une led, directement via le terminal, test� et fonctionnel
Code:
sudo i2cset -y 1 0x20 0x14 0x01
le fichier allumage.py se situe au m�me endroit que ma page en php � partir de laquelle je souhaiterai allumer ces leds.
En gros comment int�grer l'appel � allumage.py ou bien int�grerma ligne de commande que ce soit en php ou javascript ?
Cordialement.