Step 2Program notes
There are three primary tasks involved in this program:
1) Get the input voltage. The 16MHz Arduino takes 100uS to read the input, which means that even if it does nothing else, the maximum frequency it can detect reliably is 3kHz, so we use something called signal aliasing, beginning with taking a number of readings as quickly as possible (5 in our program) and summing them in separate locations. By taking averages of different ranges of samples, we can approximate the low and mid range frequencies, the difference is assumed to be the high reading. This is by no means exact science but here, we just need rough proportions, so exactness is not critical.
2) We will be doing statistical analysis of a large set of numbers, so everything is reduced to integers to save storage space and to speed up calculations. There will be no conversion from the basic 10-bit input of the Analog Input port.
3) Translation and display on the LMP. Each LED is switched on for about the time it takes to read the Analog pin, and each 'frame' (the 6 x 5 matrix) is shown twice, so that we can display 1.5db steps. This takes about 100mS. The time here is critical - any slower, the eye will start to see flicker, too fast, the 'patterns' will look dim and badly formed.
AGC is incuded, so that the program can work with a wide range of volume and music. A minimum of 150mV is required, but it should be no problem with regular listening levels. The "scale' variable can be lowered for more sensitivity, but will make the program more susceptible to electrical noise - in which casee, bypass the input with a 0.1uF capacitor to ground..
To maximize the 'dynamic' nature of the music, the most significant 2bits are dropped, and the remaining 4 are 'stretched' to fit the 6 horizontal LEDs.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|







































