Using the PIR Hat ・ 使用 PIR Hat
M5StackのPIR Hatをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| AtomS3 Lite | Controller | grove_i2c, gpio, usb_c | official page — $7.5 |
| PIR Hat | hat | gpio | official page — $3.5 |
M5Stack AtomS3 LiteとPIR Hatで作る、かんたんな人感センサーです。PIR Hatが人の動きを検知すると、AtomS3 LiteのLEDが光ります。配線はワイヤー2本だけで、はんだ付け不要です。
# M5Stack AtomS3 Lite + PIR Hat motion sensor
# Wiring: PIR Hat -> AtomS3 Lite bottom Grove port (GPIO 1 for PIR input)
import time
from machine import Pin
from neopixel import NeoPixel
# AtomS3 Lite built-in RGB LED on GPIO 27 (NeoPixel)
led = NeoPixel(Pin(27), 1)
# PIR Hat output connected to GPIO 1 (Grove port SDA pin)
pir = Pin(1, Pin.IN)
while True:
if pir.value() == 1: # motion detected
led[0] = (255, 0, 0) # red
led.write()
print("Motion detected!")
else:
led[0] = (0, 0, 0) # off
led.write()
time.sleep(0.2)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。