1
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 2026-01-22

5年程前、ラズパイ4、zeroや様々な部品を買って、何となく放置していた
スターターキットも購入していたが、それぞれ何が何の部品なのかさえもさっぱりわからない

そこで、暇つぶしに、ネットで調べながら、スターターキットの部品を1つずつ、導通していくことにした

まずは、LEDを点灯させてみます

環境

HW/SW バージョン他
筐体 Rasberry zero
OS RasberryPi OS (32-bit)
python 3.13.5
部品① LED
その他部品 ブレッドボード、ジャンパーワイアー、抵抗(1kΩ)

テキスト回路図

Rasberry ZERO(GPIO17:物理ピン11) → 抵抗300Ω~1kΩ → (+)LED(-) → ※
※ → Rasberry ZERO(GND:物理ピン6)

LEDと抵抗の順番は逆にしても問題ないです

過電流によるLEDの保護のため、必ず抵抗は入れて下さい

プログラム仕様

5秒点灯した後、消灯し、1秒後に終わるプログラムです

プログラムソース

gpio17.py
#!/usr/bin/python

import RPi.GPIO as GPIO
import time

# --- 初期化 ---
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# 使用する GPIO をすべて出力に設定
GPIO.setup(17, GPIO.OUT) #物理ピンが11のこと

# --- メイン処理 ---
GPIO.output(17, GPIO.HIGH)  # LED ON
time.sleep(5)

GPIO.output(17, GPIO.LOW)   # LED OFF
time.sleep(1)

# --- 終了処理 ---
GPIO.cleanup()
print("完了しました")

実行

pi@pi32lite:~/gpio $ python gpio17.py
完了しました
消灯時 点灯時
1
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
1
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?