0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

電子工作メモ - ボタンとLED

Last updated at Posted at 2024-03-21

押している間だけLEDを光らせる(モーメンタリスイッチ)

  • タクトスイッチ
    • 接続方向は、足が出ている側同士がボタンを押すとつながる。逆に対面側は常に繋がっている。
from machine import Pin
import time

led = Pin(15, Pin.OUT)                   
button = Pin(13, Pin.IN, Pin.PULL_UP)   # Pin13を入力として設定

try:
    while True:
        if not button.value():
            led.value(1)                # LED を ON
        else:
            led.value(0)                # LED を OFF
except:
    pass
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?