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を使う。

LED 順方向電圧 最大定格電流 推奨電流
赤色 1.9-2.2V 20mA 10mA
緑色 2.9-3.4V 10mA 5mA
青色 2.9-3.4V 10mA 5mA
  • 赤色を使う場合

    • GPIO からは3.3Vが出る
    • 10mAを流したい
      • 抵抗は、$ (3.3V - 2V) / 10mA = 0.13 * 10^3 = 130Ω $
      • 順方向電圧が約2V
      • 220オームの抵抗を使う場合、$ (3.3V - 2V) / 220Ω = 5 * 10^{-3} = 5mA $
  • 緑・青色を使う場合

    • 順方向電圧が約3V
    • 220オームの抵抗を使う場合、$ (3.3V - 3V) / 220Ω = 1 * 10^{-3} = 1mA $
    • 100オームの抵抗を使う場合、$ (3.3V - 3V) / 100Ω = 3 * 10^{-3} = 3mA $
    • 5Vを使う場合、$ (5V - 3V) / 330Ω = 9 * 10^{-3} = 6mA $
from machine import Pin
import time

led = Pin(15, Pin.OUT)   # GPIO 15を出力として設定

try:
    while True:
        led.value(1)    # LED を ON
        time.sleep(0.5) # 0.5秒スリープ
        led.value(0)    # LED を OFF
        time.sleep(0.5) # 0.5秒スリープ
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?