LED parpadeante - RASPBERRY
Hoy vamos a ver como hacer parpadear un LED con Raspberry pi.
En primer lugar montaremos el circuito, utilizaremos el GPIO 18 (pin 12) y como tierra, GND, el pin 6. Este es el esquema:
Si no tenemos instalados los paquetes de Python y de GPIO hay que introducir los siguientes comandos:
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
sudo apt-get update && sudo apt-get upgrade
A continuacion creamos un script de Python:
#!usr/bin/env/ python
#importamos la libreria GPIO
import RPi.GPIO as GPIO
import time
#Definimos el modo BCM
GPIO.setmode(GPIO.BCM)
#Ahora definimos el pin GPIO 18 como salida
GPIO.setup(18, GPIO.OUT)
for i in range(0,8):
#Y le damos un valor logico alto para encender el LED
GPIO.output(18, GPIO.HIGH)
#Esperamos 1 segundo
time.sleep(1)
#Y le damos un valor logico bajo para apagar el LED
GPIO.output(18, GPIO.LOW)
#Esperamos 1 segundo
time.sleep(1)
GPIO.cleanup()
En primer lugar montaremos el circuito, utilizaremos el GPIO 18 (pin 12) y como tierra, GND, el pin 6. Este es el esquema:
Si no tenemos instalados los paquetes de Python y de GPIO hay que introducir los siguientes comandos:
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
sudo apt-get update && sudo apt-get upgrade
A continuacion creamos un script de Python:
#!usr/bin/env/ python
#importamos la libreria GPIO
import RPi.GPIO as GPIO
import time
#Definimos el modo BCM
GPIO.setmode(GPIO.BCM)
#Ahora definimos el pin GPIO 18 como salida
GPIO.setup(18, GPIO.OUT)
for i in range(0,8):
#Y le damos un valor logico alto para encender el LED
GPIO.output(18, GPIO.HIGH)
#Esperamos 1 segundo
time.sleep(1)
#Y le damos un valor logico bajo para apagar el LED
GPIO.output(18, GPIO.LOW)
#Esperamos 1 segundo
time.sleep(1)
GPIO.cleanup()
Comentarios
Publicar un comentario