PROJECT OBJECTIVE: Build a cheer meter using a multiplexer to save Arduino i/o pins and allow for future expansions.

HARDWARE REQUIREMENTS: Provided in the Mango Labs Mechatronics Maker Kit: Arduino-compatible board, USB cable,HC-4067 Multiplexer Module, electret microphone module, 26 male to male jumper cable, 3 male to female jumper cables, 3 mini breadboards.

Additional hardware: computer, 16 LEDs (4 of each color), thin solid core wire (network), small flat screwdriver.

SOFTWARE REQUIREMENTS: Arduino environment (or online editor). Download the multiplexer library here. Unzip and paste the folder in the Arduino libraries folder. It’s in the same location as your default sketches. You can look it up under File/Preferences Sketchbook location.

KNOW-HOW REQUIREMENTS: Basic Arduino environment knowledge (learn more here). Basic electrical skills.


  1. Get some LEDs (you probably have some LEDs lying around somewhere)
  2. Connect everything as shown in the diagram.
  3. Install the multiplexer library (if you tested the board with the Hello World example you have the library already installed).
  4. Compile and upload this sketch to your board.
  5. Make noise and watch the LEDs light up.


Get your breadboards ready by attaching them together, matching the tails and slots and sliding the slots into the tails. I assembled them in a sort of mirrored P configuration.
Buy 16 LEDs or (as I did) use any you have lying around. The color choice is up to you (or to what you find available). I chose four color groups of four LEDs.
To make it easier to insert the LEDs in the breadboards bend the long leg a little away from the LED and then straight down in order to widen the space between both legs and ensure both legs have the same length.
Insert the multiplexer carefully, applying some pressure (a lot of legs have to fit) on the middle of the top left breadboard.
Insert the LEDs on the two right breadboards with the bent leg facing the multiplexer and leaving one hole space between each LED. The multiplexer has built-in resistors in each output so I didn’t use any for the sake of simplicity, but if you want to add resistors to protect or to match brightness of different colored LEDs you will need some with values around 180 ohms.
For the ground rail on the unbent (short) leg side of the LEDs I made some small bridges with bare solid core wire.
I stripped the insulation from some piece of old network wire I had laying around and used small pliers to bend them. The width of the pliers served as a spacer to ensure all jumpers had an even size. You will need 15 jumpers.
Insert the jumpers into the breadboard. If you have made them the right size they should fit nicely every 3 holes. Otherwise, bend them a little more or push them to fit; even if deformed they will work. The only thing to take care with is that the legs are long enough to make contact with the internal conductors of the breadboards.
Finish cabling the multiplexer with male to male jumper cables and the microphone module with the male to female jumper cables.
Don’t forget the jumper cable connected from the ground rail to the Arduino-compatible board ground.
With a small flat screwdriver softly tighten (CW) the small screw of the multi-turn trimm-pot to zero (you will feel a little click) in order to set the sensitivity to full range.
After cabling, make sure you have the multiplexer library installed and upload the sketch to the Arduino-compatible board.
Make some noise and watch the LEDs light up.
The peak level will stay on for 1 second.



// by Dr. Mangus for
//based on Adafruit Microphone Amplifier Sketch 
// Cheer meter
/* Make noise and visualize the amplitude differences
 * peak stays lit for 1 second.
   (tested with IDE 1.8.4 under Windows 10)
  ARDUINo conected to:
   A0  o-----------o A0     
   +5V □-----------□ +    
   GND ■-----------■ G 
   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________
   D3  o-----------o Z
   D7  o-----------o EN
   D8  o-----------o S0
   D9  o-----------o S1
   D10 o-----------o S2
   D11 o-----------o S3     
   +5V □-----------□ Vcc     
   GND ■-----------■ GND     
    Every output of the multiplexer(Y0...Y15) is connecteed to the anode (long leg)
    of each LED

#include "MUX74HC4067.h"
// Creates a MUX74HC4067 instance
// 1st argument is the Arduino PIN to which the EN pin connects
// 2nd-5th arguments are the Arduino PINs to which the S0-S3 pins connect
MUX74HC4067 mux(7, 8, 9, 10, 11);

const int sampleWindow = 50;  // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;          //Variable to store the microphone input
int volume = 0;               //Variable to store the processed microphone input
int maxvol  = 0;              //Variable to store the maximum level microphone input

unsigned long previousMillis = 0;     // will store last time maxvol was updated
const long interval = 1000;           // interval at which to hold maxvol(milliseconds)

void setup() 
    mux.signalPin(3, OUTPUT, DIGITAL);  //declaration of signal pin for the multiplexer


void loop() 
unsigned long startMillis= millis();  // Start of sample window
unsigned int peakToPeak = 0;          // peak-to-peak level
unsigned int signalMax = 0;           // Signal maximum level
unsigned int signalMin = 1024;        //Signal minimum level

     // collect data for 50 mS
   while (millis() - startMillis < sampleWindow)
      sample = analogRead(0);
      if (sample < 1024) // toss out spurious readings { if (sample > signalMax)
            signalMax = sample;  // save just the max levels
         else if (sample < signalMin) { signalMin = sample; // save just the min levels } } } peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude volume = map(peakToPeak, 1, 1023, 0, 15); //map microphone level to LED quantity volume = constrain(volume, 0, 15); //constrain to LED quantity for safety of calulations //save maximum level and time stamp if (volume > maxvol)
        previousMillis = startMillis;
//turn off maximum volume (peak) after interval time
 if (startMillis - previousMillis >= interval) 
  maxvol = 0;
    //for loop to turn the LEDs on
    for (int i = 0; i <= 15; i++) { if (i >= volume)  // blank these 
         mux.disable();  // disconnects the SIG pin from any channel
         mux.write(i, HIGH); // turn on LEDs 

   //show peak level
   if (maxvol < 1)
    mux.disable();  // don't hold peak level 0
    mux.write(maxvol,HIGH); //hold maximum volume