I just received my new arduino uno in the mail so I'm a newbie trying to learn basic electronics. Please bear with me ..
I am trying to build a VU meter using 8 LEDs and a breadboard audio jack. I've been following a tutorial I found online but I can't seem to get mine to read the proper analog input from the pin the audio jack it is assigned to. When I don't have anything plugged into the audiojack, the LEDs light up on their own and I don't understand where its receiving an input from to make the LEDs light up. Plugging in a microphone in the audiojack has no effect in the way the LEDs are lighting up. I've wired everything up following these instructions and this code. Maybe I'm missing something? I'm not sure but thanks for your help!
Here's the code:
/ Led VU Meter Example
// Version 1.0
// Written by James Newbould
// Edited a little by Zero the Geek 08-13-2013
int led[10] = { 6, 7, 8, 9, 10, 11, 12, 13}; // Assign the pins for the leds
int leftChannel = 0; // left channel input
int left, i;
void setup()
{
for (i = 0; i < 10; i++) // Tell the arduino that the leds are digital outputs
pinMode(led*, OUTPUT);*
-
//Serial.begin(9600); // Uncomment to enable troubleshooting over serial.*
}
void loop()
{
left = analogRead(leftChannel); // read the left channel
// Serial.println(left); // uncomment to check the raw input.
left = left / 50 ; // adjusts the sensitivity *edit My sensitivity is low because my phone does not have a good amplifier bulit in.
// Serial.println(left); // uncomment to check the modified input.
// left = 1500; // uncomment to test all leds light.
//left = 0; // uncomment to check the leds are not lit when the input is 0. - if (left == 0) // if the volume is 0 then turn off all leds*
- {*
- for(i = 0; i < 10; i++)*
- {*
_ digitalWrite(led*, LOW);_
_ }_
_ }*_
* else*
* {*
* for (i = 0; i < left; i++) // turn on the leds up to the volume level*
* {*
_ digitalWrite(led*, HIGH);
}*_
* for(i = i; i < 10; i++) // turn off the leds above the voltage level*
* {*
_ digitalWrite(led*, LOW);
}
}
}
*_