Il y a deux manières de travailler en mode commande (cli) avec le Raspberry :
ssh pi@adressIPduRaspberry
Pour passer root afin d'effectuer une série de tâches d'administration, utilise zla commande suivante :
$ sudo su #
Pour redenir l'utilisateur pi :
# exit
$ sudo halt $ sudo shutdown -h now
$ sudo reboot
$ sudo apt update $ sudo apt upgrade
$ sudo apt install python3 $ sudo apt install python3-pip
$sudo pip3 install RPi.GPIO
Ressources :
Le programme python doit :
#!/usr/bin/python #importation des bibliothèques import RPi.GPIO as GPIO import time #Initialisation des broches du GPIO et temporisation GPIO.setmode(GPIO.BCM) rouge=23 vert=24 orange=25 LED_list = (rouge,vert,orange) GPIO.setup(LED_list, GPIO.OUT, initial=GPIO.LOW) duree=0.5 #chenillard for i in range(3): # definir pour chaque LED de la liste son état : HIGH (allumée), LOW (éteinte) #commande équivalente à 3 instructions #GPIO.output(rouge,GPIO.HIGH) #GPIO.output(vert,GPIO.LOW) #GPIO.output(orange,GPIO.LOW) GPIO.output(LED_list,(GPIO.HIGH,GPIO.LOW, GPIO.LOW)) time.sleep(duree) GPIO.output(LED_list,(GPIO.LOW, GPIO.HIGH, GPIO.LOW)) time.sleep(duree) GPIO.output(LED_list,(GPIO.LOW,GPIO.LOW, GPIO.HIGH)) time.sleep(duree) #reset du GPIO GPIO.cleanup()