storres20 / tutorial-rp4

🍓This is a guide for everyone who wants to start using a Raspberry Pi🍓
MIT License
6 stars 1 forks source link

Blinking leds #1

Open storres20 opened 1 year ago

storres20 commented 1 year ago

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

https://user-images.githubusercontent.com/81504385/230756887-a69dd50a-6f86-4fc7-bc26-a0756c310394.mp4

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

Bibliografía