Pages: [1]   Go Down
Author Topic: Using Wave shield to light up LED's  (Read 1450 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, Noob question.
I am using an Uno with Adafruits wave shield and I want the Arduino to light up LED's when the sound level hits a certain high volume.

I also need the wave shield to start playing the audio when a button is pressed. That much I have got working but the LED's just wont respond.

I have looked at several code examples and cant get anything to work
Can somebody suggest a link or give me an example code that i can try..

I am ok at editing code to make it work for what I want, but writing from scratch is beyond me.
Any help is very much appreciated.   
Logged

Offline Offline
Edison Member
*
Karma: 32
Posts: 1288
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know anything about the Wave Shield...  But, I have made some audio activated lighting effects...

How are you wired-up?    I assume you need to feed the audio output from the Wave Shield back into one of the Arduino's analog inputs.

Or, you might be getting enough voltage out of the Wave Shield to simply connect an LED to the Wave Shield's audio output (through a resistor) if you are not too picky about the brightness.   (The LED won't be as bright with an analog signal, since there is an upper current limit for the LED, and typical audio signals have low average levels compared to their peaks.)

Or if you are playing the same sound every time, you can hard-program the timing of the LED to sync with the sound.

If you feed the audio into an analog input, be sure to add a protection diode to "short-out" the negative-going part of the audio waveform going to the Arduino.   (Negative voltages can damage the Arduino.)   And, add a resistor (maybe 1K - 10K) so that the diode doesn't "short-out" and damage the Wave Shield's actual output.

One of the simplest effects I've made simply compares the audio input (actually through a peak detector) to the 20-second moving average.   If the signal is greater than average, the light gets turned-on, otherwise it's off.   This gives a blinking effect to the sound/music that automatically adjusts to the volume.  In my program, I read and compare the audio input 10 times per second and turn the light on or off.  Once per second, I store the value in a 20-element "rotating" array/buffer and re-calculate the average.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the info.
I looked and/or considered at a lot of the things that you suggested

Due to the sound file I think i am going to hard program the timing into the code. Too many other sounds that might trigger it

I was going to edit the sound file and put 20000hz tones where i needed them to trigger the lights but I couldn't get the code to recognize them for some reason

I did write this basic code to handle the timing while the file is playing but it didn't seem to work.
Is there something I missed?
 
Code:
void loop() {
  val = digitalRead(buttonPin);                 // check button
  if (val == HIGH) {                            // button pressed
    playcomplete("hallo.wav");                      // play file
    Serial.println("Playing File");
  while (wave.isplaying)
 {
   delay(16700);
   digitalWrite(13,HIGH);
   delay(200);
   digitalWrite(13,LOW);
   delay(50);
   digitalWrite(13,HIGH);
   delay(200);
   digitalWrite(13,LOW);
   delay(50);
   digitalWrite(13,HIGH); 
   delay(150);
   digitalWrite(13,LOW);
   delay(50);
   digitalWrite(13,HIGH);
   delay(300);
   digitalWrite(13,LOW);
   delay(3000);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One other question about your idea of feeding the audio to the analog input of the arduino

I understand about the diode and its use but an audio signal is already pretty low power.

Wouldn't adding a resistor with the diode knock the power down so far that the Arduino would be able to use it?
I know I could use the serial monitor to display the values and adjust my code accordingly
But it still seems like it would be extremely low.

If i took the signal before amplification it would "really" be low,
and if I used it after the amp on the wave shield and adjusted the volume it would throw off all the values.

Am I correct or am I completely missing the mark???


 
Logged

Pages: [1]   Go Up
Jump to: