diyAudio (
-   Analog Line Level (
-   -   Arduino based LDR volume and source selection controller (

Vincent77 19th August 2015 02:40 PM

Arduino based LDR volume and source selection controller
4 Attachment(s)

I needed a remote controlled, very high audio quality attenuator for a preamplifier that I built. After considering the various options, I decided to design my own LDR volume controller.

It took a lot of effort, but it works well now, I'm pleased with the result. I would like to share the project with the DIY community, in case someone is interested.

So, here it is:
- customizable impedance, between 5kohm and 50kohm
- customizable number of attenuation steps, between 20 and 80
- you do not need matched LDRs
- LOG attenuation curve
- you can display your own welcome messages on the LCD screen
- the firmware is easy to update and modify
- remote controlled with any Apple remote
- big LCD screen, the volume level is displayed with 4-char high digits, easy to see from a distance
- the screen auto-dims to a customizable level after some inactivity time
- rotary encoder with push button
- controls up to 6 input and output stereo channels
- I/O switching is done with best quality latching relays with Silver-Palladium contacts, to avoid any degradation of the musical signal
- you can name each input and output channel
- the controller remembers the settings after power off
- can control a delay relay to soft-start a tube preamplifier
- achieves a large attenuation range by increasing series resistance at very high attenuation level and by increasing shunt resistance at very low attenuation level
- the calibration compensates for the load impedance effect
- the on-board calibration relays are best quality and they are powered only during calibration
- the LDR LEDs are working at low current (7 mA maximum), they will last a very long time
- the controller is isolated from the audio ground to avoid noise and loops
- separate linear analog and digital low noise power supplies
- power supplies on separate board, to keep the power transformer far from audio circuits
- easy to calibrate anytime from a menu – no need to plug jumpers or an external module
- better audio quality than R-2R relay attenuators (no multiple relay contacts and solder joints in the signal path, no noisy relay coils)

It is Arduino based - there are more powerful microcontrollers available, but the Arduino is much easier to work with, any amateur can easily update and customize the software.

The DACs are simply the PWM outputs switched to 31250 Hz (instead of the 500 Hz default value) and easily filtered to clean DC by two R-C cells.

The whole thing should cost around 100€ to build, much cheaper than the equivalent commercial solutions available.
I ordered the PCBs from ShenZhen2U ?PCB|Source|Assembly|Components-ShenZhen2U , where 10 pieces of 2 layer PCBs cost 10€.
You can even make the power supply and I/O boards yourself, to save some money, with the toner transfer method or even "by hand", because they are simple and single layer.

If you only need the volume control without channel switching, don't order the I/O board and parts and configure the software for either zero I/O (the volume will be displayed in the middle of the LCD in this case) or one input or output (if you still want to display a channel name).

Project status: built and confirmed.

The latest version (23 November 2015) of the project package is here:

Improved firmware by Wineds is here:

Firmware modified to support both 2004 and 1602 LCD by Howarthcd:

Zdr's custom code for OLED and LCD displays + bugfixes:

jackinnj 19th August 2015 02:48 PM

Nice job.

I've used the Arduino and the ADI ADG1414 octal switches.

petertub 23rd August 2015 10:30 AM

Du you have board(s) to sell ? Or even komplete kit's ?

Vincent77 23rd August 2015 01:31 PM

No, I don't sell boards/kits myself, but it's easy to order them online.

maxw 23rd August 2015 02:41 PM

Looks interesting. How does calibration work exactly?

Vincent77 23rd August 2015 03:43 PM

The Arduino is quite limited, it doesn't even have DAC outputs. But with some hacks, it can brilliantly do the job!

As said before, the PWM outputs are switched to 31250Hz, and thus easily filtered, making an 8 bit DAC. To overcome the low precision of this "DAC", the software can switch the driver MOSfets between two working ranges: low current and high current. This is enough to control the LDR current with acceptable precision.

The ADC inputs are oversampled to 12 bit (instead of the default 10 bit).

The target resistance values are computed for each LDR and each attenuation step. The code then searches for the needed current which gets the measured resistance as close to the target resistance as possible.

During normal use, the current through each LDR is permanently measured and fed back to the DAC control code in order to compensate for temperature drifts.

Vincent77 23rd August 2015 05:30 PM


Originally Posted by Vincent77 (
To overcome the low precision of this "DAC", the software can switch the driver MOSfets between two working ranges: low current and high current. This is enough to control the LDR current with acceptable precision.

Talking about the precision: the controller can approach the target LDR resistance within 0.1% at 1K, 1.5% at 10K and 5% at 50K

maxw 23rd August 2015 07:15 PM

Sounds interesting. Do you have a schematic as an image?

Vincent77 23rd August 2015 07:27 PM

There's a PDF schematic in the ZIP archive.

ghiglie 21st September 2015 08:47 AM

Wow, nice!
I subscribe this thread - for now I can't build one, but this is the candidate for my DCB1 volume controller... In the while, I may source some LDRs...

All times are GMT. The time now is 09:45 PM.

Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 17.65%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Copyright ©1999-2020 diyAudio