led
Inhaltsverzeichnis
LED Ansteuern
Gute Beschreibung: http://raspberrypiguide.de/howtos/raspberry-pi-gpio-how-to/
Beispiele
Bild
LED Details
LED 3mm (Boxtec 067013)
- Aufnahmespannung (IF) 10-30mA
- Vorwärtsspannung (VF) 2.2V
- Lichtstärke (IF=20mA): 80mcd
- Widerstand bei 3.5V: 220 ohm
- Widerstand bei 5V: 270 ohm
LED Rot/Grün zweifarbig (boxtec 48055)
- Durchmesser: 3mm
- Vorwärtsspannung VF: 1.8-2.3V (rot), 3.2-3.4V (grün)
- Stromaufnahme IF: 20mA
- Dominante Wellenlänge: 620 - 640nm (red), 520-530nm (green)
- Betrachtungswinkel: 20-30°
- Widerstand bei 3.5V: 220 ohm
- Widerstand bei 5V: 270 ohm
Berechung der Vorwiderstände
Vorwiderstand berechen für LED http://www.elektronik-kompendium.de/sites/bau/1109111.htm
Beispiel
Vorbereitung (via Shell)
Im Dir /sys/class/gpio befinden sich die dateien export und unexport
sudo chmod 222 /sys/class/gpio/export /sys/class/gpio/unexport
GPIO 2 verwenden
echo '2' > /sys/class/gpio/export
Python
import time import RPi.GPIO as GPIO LED_PIN = 3 # RPi.GPIO Layout verwenden (wie Pin-Nummern) GPIO.setmode(GPIO.BOARD) # Pin 18 (GPIO 24) auf Input setzen # GPIO.setup(18, GPIO.IN) # Pin LED_PIN (GPIO ?) auf Output setzen GPIO.setup(3, GPIO.OUT) # Dauersschleife while 1: # LED immer ausmachen GPIO.output(3, GPIO.LOW) # LED an GPIO.output(3, GPIO.HIGH) # Warte 100 ms time.sleep(0.1) # LED aus GPIO.output(3, GPIO.LOW) # Warte 100 ms time.sleep(0.1)
LED RGB 4 Pin ansteuern
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) RGB = [22,23,24] LEDSTATUS = [[1,0,0],[1,1,0],[1,1,1],[1,0,1],[0,1,1],[0,0,1]] for pin in RGB: GPIO.setup(pin,GPIO.OUT) GPIO.output(pin,0) try: while(True): for status in LEDSTATUS: for i in range(0,3): GPIO.output(RGB[i],status[i]) time.sleep(0.4) except KeyboardInterrupt: GPIO.cleanup()
led.txt · Zuletzt geändert: von 127.0.0.1
