module:micropython:esp32checkledsystem
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| module:micropython:esp32checkledsystem [2021/12/08 12:02] – [MicroPython: Esp32CheckLedSystem] omdevelop | module:micropython:esp32checkledsystem [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| ] | ] | ||
| + | ===== Benutzung ===== | ||
| Beispiel für die Einbindung der MicroPython-Library **LedSystem.py** : | Beispiel für die Einbindung der MicroPython-Library **LedSystem.py** : | ||
| <code python> | <code python> | ||
| + | # | ||
| + | from machine import Pin | ||
| + | # | ||
| + | class CLedSystem(): | ||
| + | # | ||
| + | def __init__(self, | ||
| + | self.PinIndex = pinindex | ||
| + | return | ||
| + | # | ||
| + | def Open(self): | ||
| + | self.Pin = Pin(self.PinIndex, | ||
| + | return | ||
| + | def Close(self): | ||
| + | self.Pin = Pin(self.PinIndex, | ||
| + | return | ||
| + | # | ||
| + | def On(self): | ||
| + | self.Pin.value(1) | ||
| + | # | ||
| + | def Off(self): | ||
| + | self.Pin.value(0); | ||
| </ | </ | ||
| Wichtig: Die Library **LedSystem.py** muss im FileSystem des MicroControllers vorhanden sein! | Wichtig: Die Library **LedSystem.py** muss im FileSystem des MicroControllers vorhanden sein! | ||
| Line 15: | Line 37: | ||
| Aufrufendes Programm **Esp32CheckLedSystem.py** : | Aufrufendes Programm **Esp32CheckLedSystem.py** : | ||
| <code python> | <code python> | ||
| + | # | ||
| + | import time | ||
| + | # | ||
| + | import LedSystem as LS | ||
| + | # | ||
| + | LedSystem = LS.CLedSystem(2) | ||
| + | LedSystem.Open() | ||
| + | for I in range(0, 100): | ||
| + | LedSystem.On() | ||
| + | time.sleep_ms(100) | ||
| + | LedSystem.Off() | ||
| + | time.sleep_ms(100) | ||
| + | LedSystem.Close() | ||
| </ | </ | ||
| - | Run-Ausgabe im Terminal: | + | Run-Ausgabe im Terminal, Programm-Ende nach 100-fachen Blinken der LedSystem: |
| < | < | ||
| - | >>> | + | >>> |
| - | >>> | + | >>> |
| - | 3 + 5 = 8 | + | |
| - | 3 - 5 = -2 | + | |
| ♦♦> | ♦♦> | ||
| MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 | MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 | ||
| Line 31: | Line 64: | ||
| ===== Version ===== | ===== Version ===== | ||
| - | {{: | + | {{: |
| - | {{: | + | |
| ===== ===== | ===== ===== | ||
module/micropython/esp32checkledsystem.1638961329.txt.gz · Last modified: 2021/12/08 13:02 (external edit)