Raspberry-Button : Différence entre versions
(Page créée avec « {{ Introduction | Cette page liste un script permettant d'interfacer le Raspberry avec un boutton }} == Schéma == <br> centré <b... ») |
m (Ajout des sources) |
||
| (Une révision intermédiaire par le même utilisateur non affichée) | |||
| Ligne 22 : | Ligne 22 : | ||
print('Button Pressed') | print('Button Pressed') | ||
time.sleep(0.2) | time.sleep(0.2) | ||
| − | </ | + | </syntaxhighlight> |
== Rafraichir une page Internet == | == Rafraichir une page Internet == | ||
| Ligne 56 : | Ligne 56 : | ||
xdotool key --window $WID F5 | xdotool key --window $WID F5 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | == Sources == | ||
| + | * http://razzpisampler.oreilly.com/ch07.html | ||
[[Catégorie:GPIO]] | [[Catégorie:GPIO]] | ||
Version actuelle datée du 26 novembre 2015 à 13:55
Cette page liste un script permettant d'interfacer le Raspberry avec un boutton
Sommaire
Schéma
Action basique
Ce script permet simplement d'afficher un message quand il y a un appui sur le boutton.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)Rafraichir une page Internet
Ce script python permet de rafraichir une page Internet ouvert dans Iceweasel via l'appel d'un script Bash pour réaliser l'action.
Script pyhton
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed to refresh')
subprocess.call("./xdotool-refresh-browser.sh", shell=True)
time.sleep(0.2)Script Bash
#!/bin/bash
WID=`xdotool search --sync --onlyvisible --class iceweasel | head -1`
#xdotool windowactivate $WID
#xdotool key F5
xdotool key --window $WID F5