0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arduinoの部品導通記録④~リレーモジュール + LED

0
Posted at

Arduinoで、リレーモジュールを通して、LEDを点灯、消灯させる導通を行った
以前の記事ラズパイによるスターターキットの部品導通記録⑥~リレーモジュール + LEDを回路そのままで、ラズパイ→Arduinoに変更したものです

環境

HW/SW バージョン他
筐体 Arduino Uno R4 Minima
IDE Arduino IDE 2.3.7
部品① 1チャンネルリレーモジュール(1 channel relay module)部品詳細
部品② LED部品詳細
その他部品 ジャンパーワイアー、ブレッドボード、抵抗(1kΩ)

回路

上下左右がわかりにくいが、リレーモージュールの突起側を向かい合わせた状態での向きとする(左← ↑上 ↓下 →右)

テキスト回路図(ラズパイ→リレーモジュール → LED)

Arduino UNO Minima       1ch Relay Module       
--------------------     ----------------- 
5V --------------------> NC(上中央 )
                      NO(上右) ---------> 抵抗(1kΩ) --> (+)LED(-) ---> Arduino[GND]へ

D7 --------------------> S(下左)
5V(物理ピン2)-----------> +(下中)
GND -------------------> -(下右)

プログラム仕様

・実行すると、2秒ごとにリレーモジュールを開閉
・リレーモジュールが開いたらLEDが点灯し、閉じたらLEDが消灯

プログラムソース

RelayLED.ino
#define RELAY_PIN 7

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);  // 初期状態はOFF(LED消灯)
}

void loop() {
  digitalWrite(RELAY_PIN, HIGH); // リレーON → LED点灯
  delay(2000);

  digitalWrite(RELAY_PIN, LOW);  // リレーOFF → LED消灯
  delay(2000);
}

実際の写真

リレーモジュール開閉のときに、カチッと音がします

リレーモジュール、LED OFF リレーモジュール、LED ON
0
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?