audio to pwm to led

Status
Not open for further replies.
Hi peeps, i have a question. iv been using the Audio System Design Tool for Teensy Audio Library (output below) and im trying to get it to output to the teensy 3.2's dac and also to a pwm pin to pulse an led in a sort of reaction. The led will need to go from like 25% lit to 100% using a dc offset mixed with the audio. i currently have the AudioOutputPWM as the pwm output but then im not sure how to set the pwm capable pin it outputs on, the info shows both pins 3 & 4 but the example just mentions pin 3. I can only use the one pin as the rest are used, i dont mind it being forced to pin 3.

Code:
// GUItool: begin automatically generated code
AudioPlaySdWav           pwav;   
AudioSynthWaveformDc     dc_offset;         
AudioMixer4              mixer;         
AudioOutputAnalog        audioout;       
AudioMixer4              LEDmixer; 
AudioSynthWaveformPWM    audio_2_pwm;          
AudioOutputPWM           blue_led_pwm;       
AudioConnection          patchCord1(pwav, 0, mixer, 0);
AudioConnection          patchCord2(pwav, 1, mixer, 1);
AudioConnection          patchCord3(dc_offset, 0, LEDmixer, 1);
AudioConnection          patchCord4(mixer, audioout);
AudioConnection          patchCord5(mixer, 0, LEDmixer, 0);
AudioConnection          patchCord6(LEDmixer, audio_2_pwm);
AudioConnection          patchCord7(audio_2_pwm, blue_led_pwm);
// GUItool: end automatically generated code
 
Audio ist way too fast to see any LED flickering. Audio frequencies are too high to be visible. From 40Hz, a really deep tone, to 16000-20000 Hz. Human eyes can see much less, like 20-50 Hz.
So you may want to write your own code to reduce the LED "speed" and make it visible. Or use the peak object or something similar. The audio-pwm is not the right choice for you.
 
Last edited:
Status
Not open for further replies.
Back
Top