Quantcast
Channel: 丁才軒討論站
Viewing all articles
Browse latest Browse all 75

Python • ESP32 & EZ StartKit / micropython

$
0
0
測試: Button A
ESP32 & EZ StartKit+ micropython

CODE:

from machine import Pin    #使用外部模組功能的動作叫做匯入 (import),匯入的有類別或函式,這邊是匯入Pin類別import time  #使用外部模組time功能led = Pin(2, Pin.OUT)      #建立Pin物件,名稱叫led ,內建LED燈button = Pin(5, Pin.IN)    #A鍵print("Init A=", button.value())#得知 button A 初值為 1 (按下時為 0)print("Init led=", led.value()) #得知 led 初值為 0 (0:暗, 1:亮[attachment=4]Q1.jpg[/attachment])time.sleep(5)print("set led")led.on()                   #led.value(1) 也可以print("led=", led.value())time.sleep(5)while True:    if button.value() == 0:        led.on()    else:        led.off()
初始設定值:
button.value() 為 1 (即未按下)
led.on()的值為 1

ESP32 + EZ Start Kit+ 組合圖
EZ Start Kit+ 擴充板 https://www.circuspi.com/index.php/educ ... zstartkit/
ESP32 配置圖 https://www.circuspi.com/index.php/educ ... zstartkit/
Q1.jpg
Q2.jpg

esp32s.jpg

統計資料: 發表於 由 dtchang — 2023-11-24, 16:50



Viewing all articles
Browse latest Browse all 75

Trending Articles