Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active Aug 10, 2019
Embed
What would you like to do?
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