Last active
August 10, 2019 18:55
-
-
Save baobao/ebd90ad9533f86336bf88be96fddd884 to your computer and use it in GitHub Desktop.
PIRセンサが反応したらLEDが光るArduinoサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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