buzzer wont turn off

hello, everyone! I’m a complete beginner in Arduino and I’m trying to make the green LED light up when the switch is off, and when it is turned on, the red will light up and buzzer will sound…

Everything else is working but My problem is that the buzzer doesnt turn off, it just changes its sound when green.

here is my code… (I dont know whether it’s the code or my setup is off)

const int tacPin = 8;
int tacValue;
const int redPin = 2;
const int greenPin = 4;
const int buzzer = 11;
void setup( ) {
// put your setup code here, to run once:
pinMode(tacPin, INPUT);
Serial.begin(9600);
pinMode(redPin , OUTPUT);
pinMode(greenPin , OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop( ) {
// put your main code here, to run repeatedly:
tacValue = digitalRead(tacPin);

Serial.println (tacValue);
delay(100);
if ( tacValue == 1)
{
//digitalWrite(buzzer, 0);
analogWrite(buzzer,0);
pinMode (greenPin, HIGH);
delay (100);
pinMode (redPin, LOW);
delay (100);
}
else
{
pinMode (redPin, 1);
//delay (100);
pinMode (greenPin, LOW);
delay (100);
analogWrite(buzzer, 100);
delay(500);
analogWrite(buzzer,0);
delay(500);
}
}

I hope you help out this newbie… thanks.

  analogWrite(buzzer,0);
  pinMode (greenPin, HIGH)

pinMode?

How is the input pin wired ?