User Tools

Site Tools


module:micropython:esp32checkledsystem

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
module:micropython:esp32checkledsystem [2021/12/08 11:21] – created omdevelopmodule:micropython:esp32checkledsystem [2022/09/13 11:58] (current) – external edit 127.0.0.1
Line 1: Line 1:
-======  ======+====== MicroPython: Esp32CheckLedSystem ======
 [[http://www.openhardsoftware.de/ | Open Hard- & Software]] [[http://www.openhardsoftware.de/ | Open Hard- & Software]]
 [ [
Line 8: Line 8:
 ] ]
  
-Esp32CheckMath | Esp32CheckMath]] +===== Benutzung ===== 
-  [[:Module:MicroPython:Esp32CheckLedSystem | Esp32CheckLedSystem]] +Beispiel für die Einbindung der MicroPython-Library **LedSystem.py** : 
-  * [[:Module:MicroPython:Esp32CheckThreading Esp32CheckThreading]]+<code python> 
 +
 +from machine import Pin 
 +
 +class CLedSystem(): 
 +  # 
 +  def __init__(self, pinindex): 
 +    self.PinIndex = pinindex 
 +    return 
 +  
 +  def Open(self): 
 +    self.Pin = Pin(self.PinIndex, Pin.OUT) 
 +    return  
 +  def Close(self): 
 +    self.Pin = Pin(self.PinIndex, Pin.IN) 
 +    return  
 +  # 
 +  def On(self): 
 +    self.Pin.value(1) 
 +  # 
 +  def Off(self): 
 +    self.Pin.value(0); 
 +</code> 
 +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()  
 +</code> 
 + 
 +Run-Ausgabe im Terminal, Programm-Ende nach 100-fachen Blinken der LedSystem: 
 +<code> 
 +>>> Running ..\Esp32CheckLedSystem.py 
 +>>> 
 +♦♦> 
 +MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 
 +Type "help()" for more information. 
 +>>> 
 +</code> 
 + 
 +===== Version ===== 
 + 
 +{{:module:micropython:2112062056_Esp32CheckLedSystem_01v01.zip 2112062056_Esp32CheckLedSystem_01v01.zip}} 
 + 
 +===== ===== 
  
 ----- -----
module/micropython/esp32checkledsystem.1638958881.txt.gz · Last modified: 2021/12/08 12:21 (external edit)