Hi, I am trying to control piezo passive buzzer with a 5V relay system.
I practiced with this piano example using a switch and pull-down, and it works fine. When I click the switch, the tone is on, and normally it is off.

int buzzerPin =8;
void setup() {
pinMode(2, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
if(digitalRead(2) == HIGH) {
tone(buzzerPin, 100, 20);
}
}
What I want is, instead of the switch, use my relay system to turn on and off the buzzer.
I already have a c++ visual studio code for sending digital output to my relay system, and successfully used in controlling other systems like controling active buzzer.
But when I connect my relay system instead of the switch, it does not work. Even though I activate my relay system to send out DO of 5V signal, no sound is generated.
The picture above is my relay system, and the connections I used in this example is colored in yellow. The red line is connected to 5V(+), the other black line is connected to the green grayhill board. And the other side of the red line is connected to number 4 in the circuit below (where switch's number 4 was, in previous example circuit). The black line is connected to place number 3.
Connection vice versa (red line-number 3, black line-number 4) generates sound continuously, even though I didn't send the DO 5V signal via relay system.
I want to know if my connections are wrong. If so, what should I do to control this passive buzzer with relay system's 5V on/off? Any advice would be helpful.


