storres20/tutorial-rp4

Blinking leds

Opened this issue · 0 comments

Raspberry Pi Pinout

URL: https://pinout.xyz/
Esta pagina web muestra 02 distribuciones de PINES (BOARD y BCM)
Para la presente, se utilizará la distribucion de PINES en BCM

Screenshot from 2023-04-09 01-05-03

Blink Led - Código

import RPi.GPIO as GPIO
from time import sleep
 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(12, GPIO.OUT, initial=GPIO.HIGH)

try: 
	while True:
		GPIO.output(7, GPIO.HIGH)
		GPIO.output(12, GPIO.LOW)
		print("LED on @ GPIO 7")
		print("LED off @ GPIO 12")
		sleep(1)
		GPIO.output(7, GPIO.LOW)
		GPIO.output(12, GPIO.HIGH)
		print("LED off @ GPIO 7")
		print("LED on @ GPIO 12")
		sleep(1)

except KeyboardInterrupt:
    GPIO.cleanup()

Pasos:

  1. Crea un nuevo archivo con el nombre 'rpi-blink.py'

  2. Inserta el codigo adjunto lineas arriba

  3. Al dar doble click en el archivo, este se abrirá con el programa GEANY
    2023-04-09-003705_1028x720_scrot

  4. Al ejecutar el codigo, este se ejecutará en una ventana de la Terminal
    2023-04-09-003833_984x630_scrot

  5. Para detener la ejecución, presionar Ctrl + C

WhatsApp.Video.2023-04-09.at.12.50.47.AM.mp4

Para mayores detalles, revisar los enlaces de la Bibliografía

Bibliografía