Raspberry Pi Picoに人感センサーとLEDをつないでMicroPythonで動かす内容をWokwiでシミュレーションしてみました。
Wokwiのアカウント作成・細かい操作についてはこちらをご参照ください。
プロジェクトを保存しなくてもよい場合はアカウントは不要です。
初めに、Wokwiのサイトにアクセスして、Micro Python Projectをクリックします。

Micro Python Projectをクリックすると、下記の画面に移動します。

回路を作成
LED、抵抗、人感センサーを配置します。+ボタンを押すと各要素のリストが表示されます。

LED, Resister, PIR Motion Sensorを選択します。

LED, Resister, PIR Motion Sensorをドラッグして、配線しやすい位置に移動します。

配線
人感センサーの+側を3V3, ー側をGND, DをGP20につなぎ、LEDの+側をGP1,ー側をGNDにつなぎます。
配線の方向を変えたいときは、配線中にクリックすると90度方向を変えることができます。
配線中が変になってしまったときは、Escキーで取り消すことができます。
画面の拡大縮小はマウスの真ん中ボタン、左右の移動は何もないところをドラッグします。

プログラムの作成
今回、人感センサーが反応するとLEDがONになる下記のプログラムを作成しました。

作成したプログラム
--------------------------------------------------------------------------------------------------------------------------------------------
import machine import utime pir = machine.Pin(20, machine.Pin.IN) led = machine.Pin(1, machine.Pin.OUT) while True: if pir.value(): led.value(1) else: led.value(0)
--------------------------------------------------------------------------------------------------------------------------------------------
プログラムの実行
▶ボタンをクリックすると、回路とプログラムともに問題なければ実行されます。
人感センサーを反応させた状態にするには、シミュレーション実行中にセンサーをクリックし、simulation motionをクリックすると、約5秒間センサーが反応した状態となります。

センサーが反応した状態

参考にしたサイトのページ
Comments