raschemmel:
You might find [this ](Tutorial: Arduino and the SPI bus | tronixstuff.com
the-spi-bus/)interesting or useful.
Thank you for the SPI tutorial, raschemmel. I only wish you could have presented it to me a year ago when I first started learning to use the SPI bus. At that time, I was getting bizarre result (including the LED going dim from the power drain) and I had no idea why. After all, I had all three SPI peripherals hooked to the same Cable Select pin (SS), so what could possibly be wrong?? :
I've saved your tutorial in my "Learn" folder. Currently, my SPI bus is running the color LCD display, the SD Card, and radio transmit/receive; all items working very well. In a few days, the speaker volume control will be joining the SPI bus.
Wawa:
Human hearing is not lineair.... write some code to simulate a log pot.
So true, Wawa. Our ears are designed that way so we can hear well over a large range of loudness. If we were linear instead, most sound would be out range, either too soft or too loud to be heard.
Instead of 50, I'm giving the user just 10 volume levels to choose from to keep it simple for them. I've already applied your logrhythmic concept to white-sound generation, like this:
byte volLevel(byte n)
{
switch (n) // each volume level is close to DOUBLE the level before it.
{ // and the effect on my ears seems just right.
case 1: return 2;
case 2: return 4;
case 3: return 7;
case 4: return 12;
case 5: return 20;
case 6: return 33;
case 7: return 55;
case 8: return 92;
case 9: return 153;
case 10: return 255;
}
return 0;
}
byte vol = volLevel(chosenLevel);
for (byte i=0; i<100; i++)
{
PORTC = random(vol); //PORTC goes to my resistor bridge,
} // converting digital to analog for the speaker amp.
Wawa:
Loading the output side with a resistor also might help.
The Secret Life of Pots
Leo..
Yes. With the speaker a resistor is not needed, but when someone wearing earbuds plugs them in, and the power that was filling the entire room is now suddenly going directly into their ear; their hearing could be permanently damaged for life! A resistor must be used to reduce the earbud sound to a level matching the percieved loudness of the speaker. Something like this:

NOTE: I've corrected this image according to the comments below.