Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active August 10, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/ebd90ad9533f86336bf88be96fddd884 to your computer and use it in GitHub Desktop.
Save baobao/ebd90ad9533f86336bf88be96fddd884 to your computer and use it in GitHub Desktop.
PIRセンサが反応したらLEDが光るArduinoサンプル
#define LED_OUTPUT 7
#define PIR_IN 2
void setup()
{
Serial.begin(9600);
pinMode(PIR_IN, INPUT);
pinMode(LED_OUTPUT, OUTPUT);
}
void loop()
{
Serial.println(digitalRead(PIR_IN));
if (digitalRead(PIR_IN) == HIGH)
{
digitalWrite(LED_OUTPUT,HIGH);
}
else
{
digitalWrite(LED_OUTPUT,LOW);
}
delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment