Arduino - Multi-Function Shield

This tutorial instructs you how to use Arduino with the Multi-Function Shield. In detail, we will learn:

Arduino Multi-Function Shield

About Multi-Function Shield

The Multi-Function Shield is an all-in-one learning and prototyping shield designed for Arduino Uno and Mega boards. It integrates several common components onto a single board, eliminating the need for complex wiring.

The shield includes the following components:

  • 4-Digit 7-Segment Display: Driven by a 74HC595 shift register. Displays numbers, text (A–Z), and special characters like the degree symbol (°).
  • 3 Push Buttons (S1, S2, S3): Active LOW with internal pullup resistors. Useful for user input and menu navigation.
  • 4 LEDs (D1, D2, D3, D4): Active LOW. Can be turned on, off, toggled, or blinked independently or all together.
  • Buzzer: Active LOW. Can produce beeps of configurable duration with optional delay.
  • Potentiometer: Connected to analog pin A0. Reads a value from 0 to 1023 (or percentage 0–100%).
  • LM35 Temperature Sensor: Connected to analog pin A4. Reads temperature in Celsius. Requires jumper J1 to be removed.

For boards based on the Arduino Uno form factor (such as the Arduino Uno or Mega), the Multi-Function Shield stacks directly onto the board, making it a true plug-and-play solution — no breadboard or jumper wires needed. For boards with Uno form factor but different pin naming (such as the DIYables ESP32-S3 Uno), the library supports custom pin mapping.

Pin Mapping

Function Arduino Pin Function Arduino Pin
LED D1 13 Button S1 A1
LED D2 12 Button S2 A2
LED D3 11 Button S3 A3
LED D4 10 Potentiometer A0
Buzzer 3 LM35 Temp Sensor A4
Display LATCH 4
Display CLOCK 7
Display DATA 8
Multi-Function Shield Pinout

Wiring Diagram

Connecting the Arduino to the Multi-Function Shield is straightforward. Simply stack the Multi-Function Shield onto the Arduino, ensuring proper alignment with the header pins, as illustrated in the image below.

Arduino Multi-Function Shield wiring diagram

This image is created using Fritzing. Click to enlarge image

Library Installation

  • Connect the Arduino board to your computer with a USB cable.
  • Open Arduino IDE, select the right board and port.
  • Navigate to the Libraries icon on the left bar of the Arduino IDE.
  • Search "DIYables_MultiFuncShield", then find the DIYables_MultiFuncShield library by DIYables.
  • Click Install button to install the latest version of the library.
Arduino Multi-Function Shield library

Note: This library is self-contained with no external dependencies.

Basic Structure

Every sketch using the Multi-Function Shield follows this basic structure:

#include <DIYables_MultiFuncShield.h> void setup() { MFS.begin(); // Initialize all components } void loop() { MFS.loop(); // Must be called every loop iteration }

MFS.begin() initializes all components (display, buttons, LEDs, buzzer). MFS.loop() updates display multiplexing, button debouncing, LED blinking, and buzzer timing. Both calls are required.

Arduino Code - 7-Segment Display

The following code demonstrates how to display integers, floats, text, and special characters on the 4-digit 7-segment display.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - Display Example * * Cycles through display features every 3 seconds: * 1. Integer number * 2. Integer with leading zeros * 3. Float number * 4. Text string with letters * 5. Text string with dot * 6. Degree symbol + C (special chars) * 7. Dashes * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> uint8_t step = 0; unsigned long lastUpdate = 0; void setup() { MFS.begin(); } void loop() { MFS.loop(); if (millis() - lastUpdate >= 3000) { lastUpdate = millis(); switch (step) { case 0: // Integer: " 42" MFS.display.print(42); break; case 1: // Integer with leading zeros: "0042" MFS.display.print(42, true); break; case 2: // Float with 2 decimals: "3.14" MFS.display.print(3.14, 2); break; case 3: // Text string: "HELP" MFS.display.print("HELP"); break; case 4: // Text with dot: "Ab.Cd" MFS.display.print("Ab.Cd"); break; case 5: // Degree + C using special chars: "25°C" MFS.display.clear(); MFS.display.setNumber(1, 2); MFS.display.setNumber(2, 5); MFS.display.setChar(3, SegChars::DEGREE); MFS.display.setChar(4, SegChars::C); MFS.display.show(); break; case 6: // Dashes: "----" MFS.display.print("----"); break; } step = (step + 1) % 7; } }

Quick Steps

  • Stack the Multi-Function Shield on the Arduino board.
  • Connect the Arduino board to your computer with a USB cable.
  • Open Arduino IDE, select the right board and port.
  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.

The display cycles through 7 modes every 3 seconds: integer, leading zeros, float, text, text with dot, degree symbol, and dashes.

Display API Summary

Method Description Example
print(int) Display integer MFS.display.print(42)
print(int, true) Integer with leading zeros MFS.display.print(42, true) → 0042
print(float, dp) Float with decimal places MFS.display.print(3.14, 2)
print(text) Display text (A-Z, 0-9, -, _) MFS.display.print("HELP")
setNumber(pos, val) Set single digit (pos 1-4) MFS.display.setNumber(1, 5)
setChar(pos, ch) Set character at position MFS.display.setChar(2, 'A')
setChar(pos, SegChars) Set special character MFS.display.setChar(3, SegCharsDEGREE)
setDot(pos) Add dot at position MFS.display.setDot(2)
clear() Clear all digits and dots MFS.display.clear()
show() Commit manual changes MFS.display.show()

Note: The print() methods call show() automatically. Use clear(), setNumber(), setChar(), setDot(), then show() for manual control.

Available special characters via SegChars: DASH (-), UNDERSCORE (_), C, E, F, DEGREE (°).

Arduino Code - Buttons

The following code detects button presses and releases, printing the events to the Serial Monitor.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - Buttons Example * * Detects button presses and releases, prints to Serial Monitor. * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> void setup() { Serial.begin(9600); MFS.begin(); } void loop() { MFS.loop(); if (MFS.button1.isPressed()) Serial.println("Button 1 pressed"); if (MFS.button1.isReleased()) Serial.println("Button 1 released"); if (MFS.button2.isPressed()) Serial.println("Button 2 pressed"); if (MFS.button2.isReleased()) Serial.println("Button 2 released"); if (MFS.button3.isPressed()) Serial.println("Button 3 pressed"); if (MFS.button3.isReleased()) Serial.println("Button 3 released"); }

Quick Steps

  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.
  • Open the Serial Monitor.
  • Press and release buttons S1, S2, and S3 on the shield to see the output.

Button API Summary

Method Description
isPressed() Returns true once when button is pressed
isReleased() Returns true once when button is released
setDebounceTime(ms) Set debounce time (default 50 ms)

Buttons have built-in debouncing and use active LOW logic with internal pullup resistors. You can access buttons by name (MFS.button1, MFS.button2, MFS.button3) or by index (MFS.button(1) to MFS.button(3)).

Arduino Code - LEDs

The following code turns on LEDs one by one, then blinks them all together.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - LEDs Example * * Demonstrates turn on, turn off, and blink for each LED. * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> void setup() { Serial.begin(9600); MFS.begin(); // Turn on all LEDs one by one Serial.println("Turn ON LEDs one by one"); for (uint8_t i = 1; i <= 4; i++) { MFS.led(i).turnON(); delay(500); } delay(1000); // Turn off all LEDs one by one Serial.println("Turn OFF LEDs one by one"); for (uint8_t i = 1; i <= 4; i++) { MFS.led(i).turnOFF(); delay(500); } delay(1000); // Blink individual LED (LED 1 only) Serial.println("Blink LED 1 individually"); MFS.led(1).blink(300); unsigned long start = millis(); while (millis() - start < 3000) MFS.loop(); MFS.led(1).turnOFF(); delay(1000); // Blink all LEDs together Serial.println("Blink all LEDs together"); MFS.allLedsBlink(500); } void loop() { MFS.loop(); }

Quick Steps

  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.

The LEDs light up sequentially with a 500 ms delay, then all 4 LEDs blink together.

LED API Summary

Method Description
turnON() Turn LED on
turnOFF() Turn LED off
toggle() Toggle LED state
blink(interval) Blink with equal on/off time
blink(onTime, offTime) Blink with separate on/off times
isOn() Returns true if LED is currently on

Convenience methods on MFS:

Method Description
allLedsOn() Turn on all 4 LEDs
allLedsOff() Turn off all 4 LEDs
allLedsBlink(interval) Blink all LEDs together
allLedsBlink(onTime, offTime) Blink all with separate on/off times

LEDs are active LOW. Access by name (MFS.led1 to MFS.led4) or by index (MFS.led(1) to MFS.led(4)).

Arduino Code - Buzzer

The following code beeps the buzzer every 2 seconds.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - Buzzer Example * * Beeps the buzzer every 2 seconds. * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> unsigned long lastBeep = 0; void setup() { MFS.begin(); } void loop() { MFS.loop(); if (millis() - lastBeep >= 2000) { lastBeep = millis(); MFS.buzzer.beep(100); } }

Quick Steps

  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.

You will hear a short beep every 2 seconds.

Buzzer API Summary

Method Description
beep(ms) Beep for the specified duration
beep(ms, delayMs) Wait delayMs, then beep for ms
stop() Stop the buzzer immediately
isBeeping() Returns true if buzzer is currently on

Arduino Code - Potentiometer

The following code reads the potentiometer and prints the value and percentage to the Serial Monitor.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - Potentiometer Example * * Reads the potentiometer and shows the percentage on the display. * * NOTE: The potentiometer on the shield is a multi-turn trimmer. * You need to rotate it MANY turns to go from 0% to 100%. * If the value stays at 0% or 100%, rotate in the opposite direction. * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> unsigned long lastUpdate = 0; float lastPct = -1; void setup() { Serial.begin(9600); MFS.begin(); Serial.println("Rotate potentiometer knob (multi-turn trimmer)."); Serial.println("It requires many turns to go from 0% to 100%."); } void loop() { MFS.loop(); if (millis() - lastUpdate >= 500) { lastUpdate = millis(); int raw = MFS.readPot(); float pct = MFS.readPotPercent(); Serial.print("Raw: "); Serial.print(raw); Serial.print(" Percent: "); Serial.print(pct, 1); Serial.print("%"); if (pct <= 0.1) Serial.print(" ← MIN (rotate clockwise to increase)"); else if (pct >= 99.9) Serial.print(" ← MAX (rotate counter-clockwise to decrease)"); Serial.println(); lastPct = pct; } }

Quick Steps

  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.
  • Open the Serial Monitor.
  • Turn the potentiometer knob and observe the value change on the Serial Monitor.

Potentiometer API Summary

Method Returns Description
readPot() int Raw ADC value (0–1023 on Uno)
readPotPercent() float Percentage (0.0 – 100.0)

Arduino Code - Temperature Sensor (LM35)

The following code reads the LM35 temperature sensor and shows the Celsius value on the display and Serial Monitor.

Important: You must remove jumper J1 on the shield to use the LM35 temperature sensor (pin A4 is shared with I2C SDA).

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-multi-function-shield */ /* * Multi-Function Shield - Temperature Example * * Reads the LM35 temperature sensor and shows Celsius on the display. * Note: Requires jumper J1 removed (pin A4). * * Hardware: DIYables Multi-Function Shield * * COMPATIBLE Multi-Function Shield: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4 Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_MultiFuncShield.h> unsigned long lastUpdate = 0; void setup() { Serial.begin(9600); MFS.begin(); MFS.display.print(0); } void loop() { MFS.loop(); if (millis() - lastUpdate >= 500) { lastUpdate = millis(); float temp = MFS.readTemperature(); MFS.display.print(temp, 1); Serial.print("Temp: "); Serial.print(temp, 1); Serial.println(" C"); } }

Quick Steps

  • Remove jumper J1 on the Multi-Function Shield.
  • Copy the above code and paste it to the editor of Arduino IDE.
  • Click Upload button on Arduino IDE to upload code to Arduino.
  • Open the Serial Monitor.
  • Observe the temperature reading on the display and Serial Monitor.

The temperature reading uses a 4-sample moving average for stable values. The buffer is automatically primed on the first read to avoid cold-start errors.

Platform Support

The library supports all Arduino platforms (architectures=*).

The Best Arduino Starter Kit

※ OUR MESSAGES