Hi guys. I tried to use the below code to print information once a time when the 3 simple sensors sense any change in its input pins, but it did not work, it keeps printing in serial monitor
int inPin = 7;
int inPin1 = 8;
int inPin2 = 9;
void setup()
{
pinMode(inPin, INPUT);
pinMode(inPin1, INPUT);
pinMode(inPin2, INPUT);
Serial.begin(9600);
}
void loop()
{
if (digitalRead(inPin) == HIGH && digitalRead(inPin1) == LOW)
{
Serial.println("DOOR #1 ACTIVATED");
delay(1000);
}
if (digitalRead(inPin) == LOW && digitalRead(inPin1) == HIGH)
{
Serial.println("DOOR #1 DEACTIVATED");
delay(1000);
}
if (digitalRead(inPin) == HIGH && digitalRead(inPin1) == HIGH)
{
Serial.println("ERROR!");
delay(1000);
}
}
So, I need some advice in how to use Pin Change Interrupt or any other way that allows me to print once a time the sensor senses any change in its inputs. Thank you so much.