// Forum: https://forum.arduino.cc/t/adding-new-but-same-sensors-in-the-program-coding/1113160
// This Wokwi project: https://wokwi.com/projects/361576771340469249
//
// Most simple sketch for three PIR sensors.
//
// Many PIR sensors have a open-collector output,
// therefor I use INPUT_PULLUP.
//
// A digitalRead() returns HIGH or LOW, and
// that is passed on to the output pin of a led.
const int pirPins[3] = { 2, 3, 4};
const int ledPins[3] = { 13, 12, 11};
void setup()
{
for( int i=0; i<3; i++)
{
pinMode( pirPins[i], INPUT_PULLUP);
pinMode( ledPins[i], OUTPUT);
}
}
void loop()
{
for( int i=0; i<3; i++)
{
int pirValue = digitalRead( pirPins[i]);
digitalWrite( ledPins[i], pirValue);
}
delay(200); // slow down the sketch
}