projekt:python_projekt_gpio
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| projekt:python_projekt_gpio [2026/02/18 09:29] – [Überblick] torsten.roehl | projekt:python_projekt_gpio [2026/02/24 07:40] (aktuell) – torsten.roehl | ||
|---|---|---|---|
| Zeile 52: | Zeile 52: | ||
| | Raspberry Pi Layout und Orientierung. | | | Raspberry Pi Layout und Orientierung. | | ||
| |{{ : | |{{ : | ||
| - | |< | + | |< |
| - | * **GND** | + | * <color # |
| - | * <color # | + | * Masse: |
| - | * <color # | + | |
| + | * <color # | ||
| + | * Versorgungsspannung: | ||
| + | * Masse: **GND** | ||
| + | | ||
| - | In diesem Kurs werden die oben aufgelisteten Pins verwendet! | ||
| </ | </ | ||
| + | |{{ : | ||
| + | |Adapterplatine zur Nutzung auf einem Steckbrett.| | ||
| + | |{{ : | ||
| + | |Alle Bauteile LED-Ampel und Temperatursensor die im Kurs verwendet werden sind angeschlossen| | ||
| ==== Verwendete Hardware | ==== Verwendete Hardware | ||
| Zeile 117: | Zeile 124: | ||
| source ~/ | source ~/ | ||
| </ | </ | ||
| - | * Für alle **Python-Projekte** im Kurs verwenden wir diese eine Umgebung: **course-env**! | + | * Für alle **Python-Projekte** im Kurs verwenden wir diese eine Umgebung: **course_env**! |
| </ | </ | ||
| ==== Pakete & Bibliotheken installieren ==== | ==== Pakete & Bibliotheken installieren ==== | ||
| Zeile 132: | Zeile 139: | ||
| <code bash> | <code bash> | ||
| - | source ~/devel/gpio_led/gpio_env/ | + | source ~/devel/projects/course_env/ |
| pip install RPi.GPIO | pip install RPi.GPIO | ||
| </ | </ | ||
| ===== Minimal Programm ===== | ===== Minimal Programm ===== | ||
| - | Dieses Programm ('' | + | Dieses Programm ('' |
| Pin und Befehl werden im **ADJUST AREA** angepasst. | Pin und Befehl werden im **ADJUST AREA** angepasst. | ||
| '' | '' | ||
| - | <code python | + | <code python |
| # | # | ||
| Zeile 148: | Zeile 155: | ||
| import RPi.GPIO as GPIO | import RPi.GPIO as GPIO | ||
| - | PIN = 17 | + | # START ADJUST AREA |
| - | VALUE = GPIO.HIGH | + | PIN = 17 |
| + | VALUE = GPIO.HIGH | ||
| + | # END ADJUST AREA | ||
| def main(): | def main(): | ||
| - | GPIO.setmode(GPIO.BCM) | + | GPIO.setmode(GPIO.BCM) |
| - | GPIO.setup(PIN, | + | GPIO.setwarnings(False) |
| + | GPIO.setup(PIN, | ||
| - | GPIO.output(PIN, | + | GPIO.output(PIN, |
| state = GPIO.input(PIN) | state = GPIO.input(PIN) | ||
| print(" | print(" | ||
| - | GPIO.cleanup() | + | |
| if __name__ == " | if __name__ == " | ||
| Zeile 167: | Zeile 177: | ||
| </ | </ | ||
| - | Programm ausführen: | + | === Programm ausführen |
| <code bash> | <code bash> | ||
| - | chmod 775 led.py # einmalig ausführbar machen! | + | chmod 775 led_simple.py # einmalig ausführbar machen! |
| - | ./led.py # Script ausführen! | + | ./led_simple.py # Script ausführen! |
| </ | </ | ||
| Hierfür muss das Programm ausführbar gemacht werden ('' | Hierfür muss das Programm ausführbar gemacht werden ('' | ||
| + | |||
| + | ===== Projekt: LED mit Python ===== | ||
| + | * [[project: | ||
projekt/python_projekt_gpio.1771406943.txt.gz · Zuletzt geändert: von torsten.roehl
