LoginSignup
1
2

More than 5 years have passed since last update.

M5GoのPIRセンサーをArduinoで使う

Last updated at Posted at 2018-11-25

目的

M5GOに入っている、PIRセンサーをArduinoで使ってみる。

準備

PIRセンサーを、
PORT Aにつなぐ場合は、GPIO22pin
PORT Bにつなぐ場合は、GPIO36pin
PORT Cにつなぐ場合は、GPIO16pin
のIOを読み取る。

実装例


#include <M5Stack.h>

const int PIN_PIR_SIG = 16;

void setup() {
  Serial.begin(115200);
  pinMode( PIN_PIR_SIG, INPUT_PULLUP );
}

void loop() {
  int i = digitalRead( PIN_PIR_SIG );
  if ( i == HIGH ) {
    Serial.print("HIGH\n");
  }
    if ( i == LOW ) {
    Serial.print("LOW\n");
  }
}
1
2
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
2