Circuit des feux de circulation Raspberry Pi avec GPIO partie 2

Circuit des feux de circulation Raspberry Pi avec GPIO partie
Circuit des feux de circulation Raspberry Pi avec GPIO partie

#Bibliotheken einbinden

importation RPi.GPIO comme GPIO

importation temps

#GPIO Modus (BOARD / BCM)

GPIO.mode réglages(GPIO.BCM)

#Warnungen ausschalten

GPIO.avertissements(Faux)

#GPIO Pin Belegung

POURRIR = 02

GELB = 14

GRUEN = 15

DÉGUSTATEUR = 07

#Richtung der GPIO-Pins festlegen (IN / OUT)

GPIO.installer(POURRIR, GPIO.EN DEHORS) #pourrir

GPIO.installer(GELB, GPIO.EN DEHORS) #gelb

GPIO.installer(GRUEN, GPIO.EN DEHORS) #gruen

GPIO.installer(DÉGUSTATEUR, GPIO.DANS) #Dégustateur

#Umschaltung definieren

def umschalten():

#Phase 2

GPIO.production(POURRIR, Vrai)

GPIO.production(GELB, Vrai)

GPIO.production(GRUEN, Faux)

temps.dormir(2)

#Phase 3

GPIO.production(GRUEN, Vrai)

GPIO.production(POURRIR, Faux)

GPIO.production(GELB, Faux)

temps.dormir(15)

#Phase 4

GPIO.production(GELB, Vrai)

GPIO.production(GRUEN, Faux)

temps.dormir(3)

#zurueck zu Phase 1

GPIO.production(POURRIR, Vrai)

GPIO.production(GELB, Faux)

#Endlosschleife

tandis que Vrai:

#La phase 1

GPIO.production(POURRIR, Vrai)

GPIO.production(GELB, Faux)

GPIO.production(GRUEN, Faux)

#Status des Tasters einlesen

tasterStatus = GPIO.contribution(DÉGUSTATEUR)

si (tasterStatus):

umschalten()

  • Geekworm 2x20 40 Pin Stacking Female Header Kit for Raspberry Pi 5 / Raspberry Pi 4 / 3B+ / 3B / 2B / B+ / Zero (Zero W) (4 Specifications), Raspberry Pi GPIO Stacking Header/Extender
    Packing List: 2 * 2x20 Female Header (Pin Len: 12mm), 2 * 2x20 Female Header (Pin Len: 10.7mm), 2 * 2x20 Female Header (Pin Len: 5.5mm), 2 * 2x20 Pin Header The 2x20 Pin Header is for Raspberry Pi Zero / Zero W. Material: Insulated plastic, hard metal pin Application: Widely be used in Raspberry Pi DIY project, such as for electronic circuit, PCB circuit board etc. electronic project Stacking header for Raspberry Pi 4, Pi 3, Pi 2, Pi Model B+, Pi A+, Pi Zero, Pi Zero W
  • ARCELI Carte d'extension RPi GPIO Breakout + Câble Ruban + Adaptateur GPIO Type T assemblé 20cm FC40 Câble Ruban Plat 40 Broches pour Raspberry Pi 3 2 Modèle B & B + SC05
    RPi GPIO assemblé avec un câble ruban de 40 "pour Raspberry pi 3B, Raspberry pi 2 modèle B, Raspberry pi 1B +, Raspberry pi 1A +, Raspberry pi zéro W, Raspberry pi zéro 1 * câble ruban arc-en-ciel 40 broches GPIO 40P 1 * carte d'extension GPIO 40 broches sont étiquetées pour un prototypage facile L'adaptateur GPIO Plus pour Raspberry Pi B +, Raspberry Pi 2, Raspberry Pi n'est pas inclus.
  • Freenove Breakout Board for Raspberry Pi 5 / 4B / 3B+ / 3B / 3A+ / 2B / 1B+ / 1A+ / Zero W/Zero, Terminal Block Hat, GPIO Status LED
    Compatible models -> Raspberry Pi 5 / 4B / 3B+ / 3B / 3A+ / 2B / 1B+ / 1A+ / Zero W / Zero. (Note: NOT compatible with Raspberry Pi 400.) GPIO status LED -> LED on if GPIO outputs/inputs high level, LED off if GPIO outputs/inputs low level. Independent LED -> The status LED is driven by the chip instead of the GPIO so the GPIO will not be affected. Terminal block and header -> Connect to all pins of Raspberry Pi's 40-pin GPIO header, 2.54mm / 0.1in pitch. GPIO name -> The BCM numbering name of each GPIO is printed next to the port.