Close

People were ready for this!

A project log for 10-bit Component-less Volume Control for Arduino!

Using PWM at an ultrasonic frequency, I've given Arduino 10-bit volume control for Tone() generation using nothing but the speaker.

lixie-labsLixie Labs 06/14/2016 at 02:410 Comments

I developed this library for my own use in a fake "cricketuino" project.

Now thousands of people have tried it, broke it, forked it, and it even caught the eye of Atmel themselves after being posted on the main HaD blog. (Go follow / like Atmel on here by the way, we owe this awesome hardware platform to them!)

In return for all the love the lib has gotten this week, I've picked development back up, and expanded much-needed compatibility to the ATmega168 / 328 / 1280 / 2560 / 16u2 / 32u4! Because each of these boards ties Timer0 to different pins, the most recent release of the Volume lib no longer allows direct assignment of speaker pins.

Volume vol(speakerPin);
is now just:
Volume vol;

With this change, a DEFAULT_PIN for each board is automatically defined, and you have the option to change it to the ALTERNATE_PIN Timer0 is also tied to for that board using:

vol.alternatePin(true);

Supported Pins:

Board DEFAULT_PIN ALTERNATE_PIN Tested
(Uno) ATmega168/328(pb) 5 6 YES
(Mega) ATmega1280/2560 4 13 YES
(Leo/Micro) ATmega16u2/32u4 9 10 YES*

*I recently killed my only ATmega32u4 board while stripping it for low-power usage and don't have one to test current releases of the library. If anyone who has a working one wants to report compatibility back to me, please do so as I've only tested the initial release!

Thank you all so much for the awesome support, let's work together to bring beautiful tones to more Arduinos! I'm currently working on the highly-demanded ATtiny support, more on that soon!

- Connor Nishijima

Discussions