Hello,
i'm an absolut newbie to microcontrollers and today I run into a problem with my PIR sensor.
Target is to activate a consumer if motion is detected. Obviously thats what a PIR is for and it works fine. Second target is to list the events in the serial monitor and here I run into a problem.
Every time a motion is detected I got three entrys in the serial monitor window (see attached jpg)
Here is the used code
int piezoPin = 4;
int pirPin = 2;
int movStatus = 0;
int movCount = 0;
void setup()
{
pinMode(piezoPin, OUTPUT);
pinMode(pirPin, INPUT);
Serial.begin(9600);
}
void loop()
{
movStatus = digitalRead(pirPin);
if (movStatus == HIGH)
{
movCount= movCount+1;
Serial.println(movCount);
digitalWrite(piezoPin, HIGH);
delay(500);
digitalWrite(piezoPin, LOW);
}
else
{
digitalWrite(piezoPin, LOW);
}
}
So how can I manage it to get only one entry for every event?
Greetings
Pawel