Cant get VU meter and sin generator to work together.
hi, i'm trying combine sin wave generator , vu meter. problem wave crested distorted.
even when disconnect led's , electret microphone i'm having problem. there wrong code itself. appreciated.
code: [select]
void loop() {
long sumofsquares = 0;
(int i=0; i<numberofsamples; i++) { //take many readings , average them
sample = analogread(1); //take reading
signal1 = (sample - middlevalue); //work out offset center
signal2 = signal1 * signal1; //square make values positive
sumofsquares += signal2; //add total
}
averagereading = sumofsquares/numberofsamples; //calculate running average
runningaverage=(((averagedover-1)*runningaverage)+averagereading)/averagedover;
/* if (runningaverage>threshold){ //is average more threshold ?
digitalwrite(ledpin, high); //if turn on led
}else{
digitalwrite(ledpin, low); //if isn't turn led off
} */
serial.println(runningaverage); //print value can check it
//delay (10);
if (runningaverage > 0)
{
digitalwrite(led[1], high);
}
else { digitalwrite(led[1], low);}
even when disconnect led's , electret microphone i'm having problem. there wrong code itself. appreciated.
bump
Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Cant get VU meter and sin generator to work together.
arduino
Comments
Post a Comment