How to connec Speaker to my LED morsecode setup

i am following this setup to build a LED morse code system to a escape room, but how can i connect a speaker that makes sound when the LED lights up.

please help me

the speaker im using is a pkm22fpp-40

Usually speakers need drivers.

found out how to do it!

i added this to my code:

const int speakerPin = 8; 

void setup() {
  pinMode(speakerPin, OUTPUT); 
}

void sendDot() {
  tone(speakerPin, 1000); 
  delay(DOT_BLNK_LEN);
  noTone(speakerPin); 
}

void sendDash() {
  tone(speakerPin, 1000); 
  delay(DASH_BLNK_LEN);
  noTone(speakerPin); 
}

You could put an active buzzer across the LED legs.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.