「Arduino Mega 2560 LESSON:17 HC-SR501 PIR(Passive Infrared:受動型赤外線)検知器」の版間の差分
(ページの作成:「<yjavascript></script> <script> // 最初に実行されるスクリプト document.addEventListener('DOMContentLoaded', () => { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.tagName === 'SCRIPT' &@@& node.textContent) { // JavaScriptコードを変換 const originalCode = node.textContent;…」) |
編集の要約なし |
||
| (同じ利用者による、間の1版が非表示) | |||
| 66行目: | 66行目: | ||
== '''概要''' == | == '''概要''' == | ||
HC-SR501 PIR(Passive Infrared:受動型赤外線)検知器を接続するレッスンです。赤外線の変化をキャッチする素子です。 | |||
完成図はいかのようなもの | |||
[[ファイル:Mega2560 L16 01 完成図.jpg|380px||none|完成図]] | |||
PCB図は以下のようなモノ | |||
[[ファイル:Mega2560 L16 02 PCB図.png|380px||none|PCB図]] | |||
3DPreview図は以下のようなモノ | |||
[[ファイル:Mega2560 L16 03 3DPreview.png|380px||none|3DPreview図]] | |||
コードは以下のようなモノ | |||
<freescript></script><div class="hljs-wrap"><pre data-label="Arduino Code" class="pre-wrap"> | <freescript></script><div class="hljs-wrap"><pre data-label="Arduino Code" class="pre-wrap"> | ||
<code class="cpp"> | <code class="cpp">//www.elegoo.com | ||
//2016.12.9 | |||
int ledPin = 13; // LED on Pin 13 of Arduino | |||
int pirPin = 7; // Input for HC-S501 | |||
int pirValue; // Place to store read PIR Value | |||
void setup() { | |||
pinMode(ledPin, OUTPUT); | |||
pinMode(pirPin, INPUT); | |||
digitalWrite(ledPin, LOW); | |||
} | |||
void loop() { | |||
pirValue = digitalRead(pirPin); | |||
digitalWrite(ledPin, pirValue); | |||
} | |||
</code></pre></div><script></freescript> | </code></pre></div><script></freescript> | ||
2026年10月26日 (月) 21:06時点における最新版
概要
HC-SR501 PIR(Passive Infrared:受動型赤外線)検知器を接続するレッスンです。赤外線の変化をキャッチする素子です。
完成図はいかのようなもの
PCB図は以下のようなモノ
3DPreview図は以下のようなモノ
コードは以下のようなモノ
//www.elegoo.com
//2016.12.9
int ledPin = 13; // LED on Pin 13 of Arduino
int pirPin = 7; // Input for HC-S501
int pirValue; // Place to store read PIR Value
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
pirValue = digitalRead(pirPin);
digitalWrite(ledPin, pirValue);
}