Pin constant high

I have a problem with digital pins 5 and 6. As soon as i set them to OUTPUT they become HIGH. and
i cannot turn them off.

Does that mean that they are defect?

Please post your code.

And your schematic.

I have a yl-44 module connected to gnd, and vcc 5v. and the data pin to digital pin 5 on a uno board.

in setup i just write

pinMode(5,OUTPUT);
digitalWrite(5,LOW);

but the speaker keep making a sound. i also tried with analogWrite(5,0) as it uses PWM.

HIGH turns it off.

gumbas:
i also tried with analogWrite(5,0) as it uses PWM

Not from the microcontroller...

...without needing a dedicated PWM channel.

https://www.openimpulse.com/blog/products-page/product-category/active-buzzer-module-and-cable/

It dosen't explain why i cannot set the port low = no voltage.

Yes it does :wink: There is actually no voltage on pin 5. But the buzzer is made in a way it's active low. So:
digitalWrite(pin, LOW); //turns it on
digitalWrite(pin, HIGH); //turns in off

Do you actually measure voltage on the pin?

then:
Perhaps there is something else wrong in your code, could you post it all?

i have not measured the voltage, but i took a wire from a relay and connected it to the pin 5 after i was set to low and the relay turned on.

i will measure the voltage level on the pin.

Have you even read my comment?

If it's indeed this buzzer than this is it schematic. The buzzer is active low. So setting the output low will turn on the buzzer. You have to make the output high to make it shut up.

gumbas:
i have not measured the voltage

Why not???

gumbas:
but i took a wire from a relay and connected it to the pin 5 after i was set to low and the relay turned on.

a wire from a relay. You can't make it any more vague :wink:

Im an idiot :slight_smile:

I measured the voltage and it vas 5v on high and 0v on low. further more the buzzer stopped on pin high.

i need to read up on basic eletronic.

And that's why there is a saying in dutch: "Meten is weten" (Measuring is knowing)