Controlling QuadVol with Arduino/Sparrow

quadvol-arduinoIt is very easy to control the Quad Volume Control circuit with an Arduino. You can use an Arduino board of your choice or the Arduino compatible Sparrow board that is available in our shop. You only need 3 ports for the control: CS, CLOCK, DATA.

Here is an example of a software SPI implementation. You can also use hardware SPI. But make sure, that the frequency is low enough for the optocouplers! You will not be able to use high SPI clocks in the Megahertz range. Read the datasheet to make sure it will work. With 1kOhm load resistors on the optocouplers, 10kHz SPI frequency should be possible.  You have to transmit only 4 bytes to change the volume. Even with an SPI clock of 1 kHz, this will only take 32ms.

This example uses a Teensy 2 board, but it should work on all Arduino compatible boards. You have to configure the ports for CS, CLOCK and DATA based on your hardware setup.

int led = 11; // Teensy 2.0 LED
int cs = 0; // B0
int clock = 1; // B1
int data = 2; // B2

int cycle = 1; // 1ms clock cycle

void setup() {
  // initialize outputs
  pinMode(led, OUTPUT);
  pinMode(cs, OUTPUT);
  pinMode(data, OUTPUT);


// set the volume on all 4 channels to the same level
// 0 = mute
// 255: +31.5db
// note that all signals are inverted!!!
void setVolume(byte vol) {

  // we're using software-SPI here, because the SPI frequency is very low and 
  // we have to invert some signals
  digitalWrite(cs, HIGH);

  // set volume 4 times
  for (byte b=0; b<=4; b++) {
    byte b=vol;
    for (byte bv=0; bv<=8; bv++) {
      if (b & 0x80) {
      } else {
      b <<= 1;

  // all to low again
  digitalWrite(cs, HIGH);
  digitalWrite(data, HIGH);
  digitalWrite(clock, HIGH);

You want to control the volume from your tablet or mobile phone? Have a look at this cool project.

You do not want to program it by yourself? Have a look on our QualVol Control project on GitHub. This implements a control circuit that can be controlled by an IR remote control, a rotary sensor or 3 push buttons.

7 thoughts on “Controlling QuadVol with Arduino/Sparrow

  1. Pingback: A first look on the 4 channel volume control | Crazy Audio

  2. matuschd Post author

    Hi Andreas,

    as the example uses a software-SPI, you can use any pins you like. Notice, that with normal optocouplers, you won’t run the SPI at high speeds, but only at 1kHz (depending on the optocoupler you use, it can be faster). But this is not a problem, because you only have to transmit 4 bytes to set a new volume)

    For the pin assignment on the QuadVol board, check out the documentation at


  3. Andreas

    in the example code all signals are inverted. With the board rev. 1.1 and a standard arduino this is wrong! The chip-select with inverted signal disable the quad-volume-control and you get nothing. Please correct the example for arduino.

    1. Daniel Post author

      Hi Andreas,

      thank you for the feedback. As I do not have an Arduino here for tests, can you confirm, that ALL signals are inverted? Or is it the CS signal only?

      Best regards

      1. Andreas

        you need no inverting for all signals. In your example change all “HIGH”-Values to “LOW” and all “LOW”-Values to “HIGH” . After that the board is working :)…


Leave a Reply