7 seg display counting PIR sensor input

Basically trying to get help counting every time PIR sensor indicates movement on 7 seg display need help with code

Do start by posting the code you have, the schematics, etc.
Don’t forget to read the sticky as well.

ok Basically I have a simple PIR alarm that goes off every time motion is detected below I will provide the code for that, im trying to add a simple counter that will count every time the alarm goes off and display it on the 7 seg display of which I only have code that counts up or down. I just need help combing the two. where to put the counter code under VOID LOOP and what too actually include in setup etc…

//PIR ALARM CODE

int buzzerPin = 8; //BUZZER INPUT PIN.
int ledPin = 13; //LED PIN.
int pirPin = A0; //MOTION SENSOR INPUT PIN.
int sensorValue = LOW; //DEFAULT SENSOR STATE.

void setup() { //INITIAL SETTINGS/ASSIGNMETN.
pinMode(buzzerPin, OUTPUT); //SET BUZZER AS OUTPUT.
pinMode(ledPin, OUTPUT); //SET LED AS OUTPUT.
pinMode(pirPin, INPUT); //SET PIR AS INPUT.
}
void loop() { //COMMAND TO BE REPEATED.
sensorValue = digitalRead(pirPin); //READ PIR INPUT PIN.
if ( sensorValue == HIGH) { //IF MOTION IS DETECTED.
tone(buzzerPin, 1200); //BUZZ THE BUZZER.
digitalWrite(ledPin, HIGH); //ON LED.
delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
noTone(buzzerPin); //SILENT BUZZER.
digitalWrite(ledPin, LOW); //OFF LED.
delay(100); //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
}
else { //IF NO MOTION IS DETECTED.
noTone(buzzerPin); //SILENT THE BUZZER.
digitalWrite(ledPin, LOW); //OFF LED.
}
}

//7 SEG DISPLAY COUNTER CODE

#define segA 2//connecting segment A to PIN2
#define segB 3// connecting segment B to PIN3
#define segC 4// connecting segment C to PIN4
#define segD 5// connecting segment D to PIN5
#define segE 6// connecting segment E to PIN6
#define segF 7// connecting segment F to PIN7
#define segG 8// connecting segment G to PIN8

int COUNT=0;//count integer for 0-9 increment
void setup()
{
for (int i=2;i<9;i++)
{
pinMode(i, OUTPUT);// taking all pins from 2-8 as output
}
}

void loop()
{
switch (COUNT)
{

case 0://when count value is zero show”0” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, LOW);
break;

case 1:// when count value is 1 show”1” on disp
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;

case 2:// when count value is 2 show”2” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, LOW);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;

case 3:// when count value is 3 show”3” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, HIGH);
break;

case 4:// when count value is 4 show”4” on disp
digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;

case 5:// when count value is 5 show”5” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;

case 6:// when count value is 6 show”6” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, LOW);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;

case 7:// when count value is 7 show”7” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, LOW);
digitalWrite(segE, LOW);
digitalWrite(segF, LOW);
digitalWrite(segG, LOW);
break;

case 8:// when count value is 8 show”8” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;

case 9:// when count value is 9 show”9” on disp
digitalWrite(segA, HIGH);
digitalWrite(segB, HIGH);
digitalWrite(segC, HIGH);
digitalWrite(segD, HIGH);
digitalWrite(segE, LOW);
digitalWrite(segF, HIGH);
digitalWrite(segG, HIGH);
break;

break;
}
if (COUNT<10)
{
COUNT++;
delay(1000);///increment count integer for every second
}
if (COUNT==10)
{
COUNT=0;// if count integer value is equal to 10, reset it to zero.
delay(1000);
}
}

far less pins if you use an I2C backpack for the display. adafruit makes a good one and an excellent library to go with it. then its as easy as...
if PIR is HIGH or LOW depending on pir module. then, count++. print count.

Do add state tracking as you want to count only on change of signal (i.e. going high, not being high - or low, for that matter).