Taula de continguts:

Tutorial de Raspberry Pi sobre el parpelleig del LED: 4 passos
Tutorial de Raspberry Pi sobre el parpelleig del LED: 4 passos

Vídeo: Tutorial de Raspberry Pi sobre el parpelleig del LED: 4 passos

Vídeo: Tutorial de Raspberry Pi sobre el parpelleig del LED: 4 passos
Vídeo: Home Assistant. Урок 9.4 ADD-ON - Xiaomi Gateway 3, интеграция в zigbee2mqtt 2024, Juliol
Anonim
Image
Image

Requisit:

  • Raspberry Pi
  • BreadBoard o T-Cobbler
  • Filferros de pont
  • LED

Feu clic aquí per obtenir més informació

Pas 1: connecteu el vostre Raspberry Pi GPIO amb LED a la placa de pa o al tauler multifunció

Configuració
Configuració

Ara, segons el vídeo, podeu utilitzar el número 27 com a sortida i connectar GND amb el terminal GND del led, Assegureu-vos que la vostra connexió GPIO sigui correcta.

Pas 2: Configuració

Connecteu el LED a la panaderia o al sabater com a vídeo adjunt.

Pas 3: instal·leu les biblioteques GPIO

$ sudo apt-get update

$ sudo apt-get install python-rpi.gpio python3-rpi.gpio

Pas 4: programa

importar RPi. GPIO com a GPIO

temps d'importació

LedPin = 11 # pin11

def setup ():

GPIO.setmode (GPIO. BOARD) # Numera els GPIO per ubicació física

GPIO.setup (LedPin, GPIO. OUT) # S’estableix el mode de LedPin

GPIO.output (LedPin, GPIO. HIGH) # Estableix LedPin alt (+ 3,3 V) per encendre el led

parpelleig definitiu ():

mentre que és cert:

GPIO.output (LedPin, GPIO. HIGH) # encès

dormir (1)

GPIO.output (LedPin, GPIO. LOW) # led off time.sleep (1)

def destroy ():

GPIO.output (LedPin, GPIO. LOW) # desactivat

GPIO.cleanup () # Recurs de llançament

si _nom_ == '_principal_':

setup ()

provar:

parpellejar ()

excepte KeyboardInterrupt:

destruir ()

Recomanat: