hi everyone I want make spectrum analyzer meter led with arduino uon
with switch to change type display
more difficulty from this code
any one help me plzzzzzz :o :o :o :o
int tempo=10; //regolare a piacere
int soglia = 10 ;
int valore = 0 ;
void setup() {
for (int i=2;i<=13;i++)
{
pinMode (i, OUTPUT);
}
Serial.begin(9600);
}
void loop() {
delay(tempo);
valore = analogRead(A0); //Serial.print("Valore audio: "); //l'output sulla seriale rallenta i led //Serial.println(valore);
if ( (soglia *1) <valore) {digitalWrite (13 ,HIGH);} else {digitalWrite (13 ,LOW);}
if ( (soglia *2) <valore) {digitalWrite (12 ,HIGH);} else {digitalWrite (12 ,LOW);}
if ( (soglia *3) <valore) {digitalWrite (11 ,HIGH);} else {digitalWrite (11 ,LOW);}
if ( (soglia *4) <valore) {digitalWrite (10 ,HIGH);} else {digitalWrite (10 ,LOW);}
if ( (soglia *5) <valore) {digitalWrite (9 ,HIGH);} else {digitalWrite (9 ,LOW);}
if ( (soglia *6) <valore) {digitalWrite (8 ,HIGH);} else {digitalWrite (8 ,LOW);}
if ( (soglia *7) <valore) {digitalWrite (7 ,HIGH);} else {digitalWrite (7 ,LOW);}
if ( (soglia *8) <valore) {digitalWrite (6 ,HIGH);} else {digitalWrite (6 ,LOW);}
if ( (soglia *9) <valore) {digitalWrite (5 ,HIGH);} else {digitalWrite (5 ,LOW);}
if ( (soglia *10) <valore) {digitalWrite (4 ,HIGH);} else {digitalWrite (4 ,LOW);}
if ( (soglia *11) <valore) {digitalWrite (3 ,HIGH);} else {digitalWrite (3 ,LOW);}
if ( (soglia *12) <valore) {digitalWrite (2 ,HIGH);} else {digitalWrite (2 ,LOW);}
}.
I can't watch the video 'cause I'm at work... But, I know what a spectrum analyzer is and I've seen it done with the Arduino.
Do you understand how your current code works or did you just copy it from somewhere? ...It can be very frustrating if you try to copy someone else's project and you don't understand how it works.
What are you doing about the negative half of the AC audio waveform? The Arduino can't (directly) read negative voltages and in fact it can be damaged by negative voltages. If you simply clip-off the (or ignore) the negative half of the waveform that will introduce severe distortion and that will mess-up your frequency analysis (spectrum analyzer).
There are a couple of ways to make a spectrum analyzer -
There is a chip called the [u]MSGEQ7[/u] that takes an audio signal as input and puts-out 7 time-multiplexed DC voltages. The timing is critical and the MSGEQ7 needs a (software generated) clock, so the code isn't super-simple, but it's the simplest way to make a 7-band spectrum analyzer effect.
Another popular approach is to use [u]FFT[/u] (or DFT/FHT) to do the frequency analysis in software. The code is quite a bit more complicated, but there are libraries so you don't have to write it all from scratch.
And, you'll need some additional hardware (and software) and way to address & drive many LEDs.
This example I published implements a 60 band by 32 level (1920 addressable LEDs) spectrum display, based on 1024 point FFT. It won't run on Uno, but if you can step up to a more powerful board... maybe it'll help?
@alikut99: What you say you want is a spectrum analyzer. But the code you posted is a simple attempt at a VU meter. The youtube video also shows a VU meter.
A VU meter is not a spectrum analyzer.
Which do you want?