Connecting LED and speaker

Hi guys I am new and I am working on a project for school I have one LED and one small speaker which plays tones.. I didn't find any articles that would help me with this.. I need the LED (exactly 1) to shine to the melody that the speaker plays or something along the lines.. I would appreciate all your help, thank you very much

Do you have to generate a tone, or are you supposed to detect it and visualise it with the LED?

detect and visualize, I managed to use digitalWrite(LED, HIGH); digitalWrite(beep, HIGH); for it but the speaker doesn't really produce any tone it just makes a clicky sound this way

Then I suppose you have a module that looks like this?

Nope all i have is a small speaker, one LED, arduino UNO and a breadboard + cables ofc

A speaker can be used as a microphone but it doesn't do a particularly good job.

What kind of speaker is it?

I guess you can wire the speaker to one of the analogue inputs and see whether you can pick something up...

A resistor for the LED, 330 ohms.

ToneLibrary - Arduino Reference might be useful. The LED can be synched with the tone production.

image

the speaker looks like this

Yes that's what I need, a way to sync the LED to the tone production

Drive the LED with the same signal producing the tone.

With the analogRead threshold very low and if justliv shouts into it. . . maybe.

I can see a + sign on the molded case, so you have an ACTIVE piezo buzzer.

""...LED to shine to the melody that the speaker plays or something along the lines...""

Define what that actually means. Computers and micro-controllers do not take "something like that-commands".

Maybe try PWM on the LED to control the brightness. Low tone > low brightnes, high tone > high brightness. Search for "arduino pwm led brightness" and have a look here: map() - Arduino Reference

And also: tone() - Arduino Reference

Means that when the speaker makes a sound led lights up

tone()
digitalWrite()
noTone()
digitalWrite()

There will be no "detection".

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