Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » 12-Bit DAC Usage Guide in Arduino UNO R4 Minima
Arduino Projects

12-Bit DAC Usage Guide in Arduino UNO R4 Minima

Mamtaz AlamBy Mamtaz Alam5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Introduction

This guide is about 12-bit DAC Usage in Arduino UNO R4 Minima Microcontroller Board.

The Arduino R4 Minima is a versatile microcontroller board designed for both beginners and experienced users. One of its key features is the 12-bit Digital-to-Analog Converter (DAC). DACs are important in many electronic systems because they change digital values back into analog signals. These analog signals can then interact with other parts of the system or be measured.

Most standard Arduino boards don’t have a built-in DAC. Therefore we have to use external DACs like MCP4725. However, the R4 Minima version comes with a 12-bit DAC. This means it can produce 4,096 different analog values, giving users more control and precision in their projects.

In this guide, we’ll show you how to use the 12-bit DAC on the Arduino R4 Minima. We’ll talk about its benefits and provide some useful tips. Additionally, we will explore the generation of various waveforms using the DAC such as Sine, Square, and Sawtooth waveforms.

  • Read this first: Arduino UNO R4 Minima Getting Started Guide
  • ADC Usage Guide: 14-Bit ADC Usage in Arduino UNO R4 Minima
  • Recommended R4 Minima Kit: SunFounder Ultimate Kit



DAC Pin in Arduino UNO R4 Minima Board

The Arduino UNO R4 Minima has a built-in DAC (Digital-to-Analog Converter) with up to 12-bit resolution. This DAC is attached to the A0 analog pin. It can act as a genuine analog output pin, making it more versatile than PWM pins.

DAC Pin Arduino R4 Minima

By default, the DAC pin has a write resolution of 8 bits but can be changed to 10-Bit or 12-Bit in coding part.


Features of DAC in Arduino UNO R4 Minima Board

  1. Enhanced Output Precision: The R4 Minima board is equipped with a 12-bit DAC, a step up from boards that might not have a built-in DAC. This allows it to generate analog output with greater precision, offering 4,096 discrete output values.
  2. Variable Output Range: The DAC allows users to select between different output voltage ranges, providing flexibility in generating the desired analog signal.
  3. High-Speed Signal Generation: The DAC in the R4 Minima is designed for rapid signal generation, making it suitable for applications that require real-time analog signal output.
  4. Noise Filtering Capabilities: The DAC comes with features that filter out noise, ensuring that the generated analog signal is clean and accurate.
  5. Multiple Waveform Generation: The DAC can produce various waveforms, such as sine, square, and sawtooth. This versatility is beneficial for applications ranging from audio signal generation to test signal outputs.




Hardware Setup for DAC Usage

Lets setup the Arduino UNO R4 Minima Board to generate discrete output voltages from 0 to 5 volts using the DAC Pin. The DAC Pins can also be used to generate waveforms which will be demonstrated here.

Connection Steps:

  1. Potentiometer Ground: Connect one of the outer pins of the potentiometer to the Arduino’s GND pin.
  2. Potentiometer Voltage: Connect the other outer pin to the Arduino’s 5V pin.
  3. Signal to A5: Connect the potentiometer’s middle pin (wiper) to the A5 pin on the Arduino.

12-Bit DAC Setup Arduino UNO R4 Minima

Ensure all connections are secure. Now, the potentiometer can control the frequency of the waveforms. The output from A0 pin and GND is directly connected to the Oscilloscope.


Sine Wave Generator

The first application of DAC of Arduino UNO R4 Minima is generation of Sine Waveform. Generating a sine wave using is a great way to produce a smooth analog waveform.

Here is the code to generate the waveform. Copy the code and paste it on your Arduino IDE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "analogWave.h" // Include the library for analog waveform generation
 
analogWave wave(DAC);   // Create an instance of the analogWave class, using the DAC pin
 
int freq = 10;  // in hertz, change accordingly
 
void setup()
{
  Serial.begin(115200);  // Initialize serial communication at a baud rate of 115200
  wave.sine(freq);       // Generate a sine wave with the initial frequency
}
 
void loop()
{
  // Read an analog value from pin A5 and map it to a frequency range
  freq = map(analogRead(A5), 0, 1024, 0, 10000);
 
  // Print the updated frequency to the serial monitor
  Serial.println("Frequency is now " + String(freq) + " hz");
 
  wave.freq(freq);  // Set the frequency of the waveform generator to the updated value
  delay(1000);      // Delay for one second before repeating
}

After uploading the code to the Arduino Board, setup the oscilloscope to see the waveform.

Arduino UNO R4 Sine Wave Generator

The generated waveform looks similar to sine wave.

When the scaling is done, the quantization level can be clearly observed.

12-Bit DAC Arduino R4 Minima Sine Wave



Square Wave Generator

After generating the sine wave, the Arduino UNO R4 Minima DAC Pin can also be used to generate the square waveform. Generating a square wave is a straightforward task. The DAC will alternate between two voltage levels to create the square wave.

Here is the code for this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "analogWave.h" // Include the library for analog waveform generation
 
analogWave wave(DAC);   // Create an instance of the analogWave class, using the DAC pin
 
int freq = 10;  // in hertz, change accordingly
 
void setup()
{
  Serial.begin(115200);  // Initialize serial communication at a baud rate of 115200
  wave.square(freq);     // Generate a square wave with the initial frequency
  wave.begin(freq);      // Begin the waveform generation
  wave.start();          // Start the waveform generation
}
 
void loop()
{
  // Read an analog value from pin A5 and map it to a frequency range
  freq = map(analogRead(A5), 0, 1023, 0, 10000);
 
  // Print the updated frequency to the serial monitor
  Serial.print("Frequency is now ");
  Serial.print(freq);
  Serial.println(" hz");
 
  wave.freq(freq);  // Set the frequency of the waveform generator to the updated value
  
  delay(1000);      // Delay for one second before repeating
}

After uploading the above code the Oscilloscope can be adjusted to observe the square wave.

Arduino UNO R4 Square Wave Generator

When the waveform is observed closely, the alternation between the wave is a straight line.

12-Bit DAC Arduino R4 Minima Square Wave


Sawtooth Wave Generator

Generating a Sawtooth wave using Arduino UNO R4 Minimo involves incrementing and decrementing the DAC output in a loop to create a linear rise and fall in voltage.

Here is the code for this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "analogWave.h" // Include the library for analog waveform generation
 
analogWave wave(DAC);   // Create an instance of the analogWave class, using the DAC pin
 
int freq = 10;  // in hertz, change accordingly
 
void setup()
{
  Serial.begin(115200);  // Initialize serial communication at a baud rate of 115200
  wave.saw(freq);        // Generate a sawtooth waveform with the initial frequency
  wave.begin(freq);      // Begin the waveform generation
  wave.start();          // Start the waveform generation
}
 
void loop()
{
  // Read an analog value from pin A5 and map it to a frequency range
  freq = map(analogRead(A5), 0, 1023, 0, 10000);
 
  // Print the updated frequency to the serial monitor
  Serial.print("Frequency is now ");
  Serial.print(freq);
  Serial.println(" hz");
 
  wave.freq(freq);  // Set the frequency of the waveform generator to the updated value
  
  delay(1000);      // Delay for one second before repeating
}



After uploading the above code, adjust the Oscilloscope settings to observe the sawtooth wave.

Arduino UNO R4 Sawtooth Wave Generator

The waveform generated looks a perfect sawtooth wave.

The digital to analog conversion can only be observed when the waveform is more and more expanded.

12-Bit DAC Arduino R4 Minima Sawtooth Wave


Conclusion

Throughout our exploration, we’ve seen the versatility of the Arduino UNO R4 12-Bit DAC Pin.It has a great ability to generate a variety of analog voltages. The practical application of DAC is in generating varios waveforms like Sine, Square, and Sawtooth Waveform.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterfacing 0-25V DC Voltage Sensor with Arduino
Next Article LoRa-Enabled IoT Geo-Fencing using GPS, Arduino & ESP8266

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • IoT Based Electricity Energy Meter using ESP32 & Blynk
    IoT Based Electricity Energy Meter using ESP32 & Blynk
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.