module:micropython:esp32checkledsystem
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
module:micropython:esp32checkledsystem [2021/12/08 11:21] – created omdevelop | module:micropython:esp32checkledsystem [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
[[http:// | [[http:// | ||
[ | [ | ||
Line 8: | Line 8: | ||
] | ] | ||
- | Esp32CheckMath | Esp32CheckMath]] | + | ===== Benutzung ===== |
- | * [[:Module:MicroPython:Esp32CheckLedSystem | Esp32CheckLedSystem]] | + | Beispiel für die Einbindung der MicroPython-Library **LedSystem.py** : |
- | * [[:Module: | + | <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! | ||
+ | |||
+ | Aufrufendes Programm **Esp32CheckLedSystem.py** : | ||
+ | <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, Programm-Ende nach 100-fachen Blinken der LedSystem: | ||
+ | < | ||
+ | >>> | ||
+ | >>> | ||
+ | ♦♦> | ||
+ | MicroPython | ||
+ | Type " | ||
+ | >>> | ||
+ | </ | ||
+ | |||
+ | ===== Version ===== | ||
+ | |||
+ | {{:module: | ||
+ | |||
+ | ===== ===== | ||
----- | ----- |
module/micropython/esp32checkledsystem.1638958881.txt.gz · Last modified: 2021/12/08 12:21 (external edit)