int pir_sensor_pin = 2, light_1 = 13;
void setup() {
Serial.begin(9600);
pinMode(pir_sensor_pin, INPUT);
pinMode(light_1, OUTPUT);
}
void loop() {
boolean pir_data = digitalRead(pir_sensor_pin); //read PIR sensor data
if (pir_data == 0) //check activity
{
digitalWrite(light_1, LOW); //turn off light
}
else
{
digitalWrite(light_1, HIGH); //turn on light
}
}