Go Down

Topic: Playing audio from SD card and controlling LED at the same time (Read 352 times) previous topic - next topic

Gianluke

Hi, as title, I wonder if it is possible to make arduino read and play a .wav file from an SD card and controlling one or more LED, (possibly by PWM, that would be even better), at the same time, in order to create light effects together with the music.

(I want to consider this for some projects involving lights and sound, like a digital music box, a space gun a car model etc.)

I tried playing songs with the TMRpcm.h library, but it seems that when tmrpcm.play("song.wav"); starts playing the song, next lines will be executed only when the song is finished.

I guess something could be done by inserting into a while(millis() < song_duration) cycle the LED effects controlled by more and more while cycles, but I still can't figure out how.

Any hints? Thank you very much.

Gianluca

Go Up