Introduction to the SAMD21 Microcontroller
The SAMD21 is a powerful and versatile microcontroller that has gained popularity among Arduino enthusiasts and embedded systems developers. Developed by Microchip Technology (formerly Atmel), the SAMD21 is based on the ARM Cortex-M0+ architecture and offers a range of features and capabilities that make it an excellent choice for a wide variety of projects.
Key Features of the SAMD21
- 32-bit ARM Cortex-M0+ core
- Operating frequency up to 48 MHz
- Up to 256 KB of Flash memory and 32 KB of SRAM
- Peripheral Touch Controller (PTC) for capacitive touch sensing
- Advanced Analog-to-Digital Converter (ADC) with up to 12-bit resolution
- Digital-to-Analog Converter (DAC) with 10-bit resolution
- Multiple communication interfaces, including UART, I2C, SPI, and USB
- Low power consumption with various sleep modes
Why Choose the SAMD21 for Your Arduino Projects?
Enhanced Performance
The SAMD21’s 32-bit ARM Cortex-M0+ core and 48 MHz operating frequency provide a significant performance boost compared to traditional 8-bit Arduino boards. This extra processing power enables you to tackle more complex projects and algorithms, such as digital signal processing, advanced robotics, and high-speed data acquisition.
Increased Memory Capacity
With up to 256 KB of Flash memory and 32 KB of SRAM, the SAMD21 offers ample storage space for your sketches and data. This increased memory capacity allows you to develop more sophisticated applications without worrying about running out of memory, a common limitation in 8-bit Arduino boards.
Native USB Support
The SAMD21 features native USB support, which simplifies the process of connecting your Arduino board to a computer. This feature eliminates the need for an additional USB-to-serial converter chip, reducing the overall cost and complexity of your projects. Native USB support also enables faster data transfer rates and improved compatibility with various operating systems.
Rich Peripheral Set
The SAMD21 boasts an extensive set of peripherals that expand the microcontroller’s capabilities beyond those of traditional Arduino boards. Some notable peripherals include:
- Peripheral Touch Controller (PTC): The PTC enables capacitive touch sensing, allowing you to create intuitive and responsive user interfaces for your projects.
- Advanced Analog-to-Digital Converter (ADC): With up to 12-bit resolution and a sampling rate of 350 ksps, the SAMD21’s ADC provides high-quality analog measurements for sensor-based applications.
- Digital-to-Analog Converter (DAC): The 10-bit DAC allows you to generate analog signals, which is useful for audio applications, signal generation, and control systems.
- Multiple Communication Interfaces: The SAMD21 supports various communication protocols, including UART, I2C, SPI, and USB, making it easy to interface with a wide range of sensors, displays, and other peripherals.
Low Power Consumption
The SAMD21 is designed with power efficiency in mind. It offers several sleep modes that allow the microcontroller to conserve energy when not in use. This feature is particularly beneficial for battery-powered projects or applications that require long-term deployment, such as remote sensors or wearable devices.

Popular SAMD21-Based Arduino Boards
Several Arduino boards leverage the SAMD21 microcontroller, offering users a familiar development environment while benefiting from the enhanced features and performance of the SAMD21. Some popular SAMD21-based Arduino boards include:
- Arduino Zero: The Arduino Zero is a compact and powerful board that serves as an excellent introduction to the SAMD21 microcontroller. It features 256 KB of Flash memory, 32 KB of SRAM, and native USB support.
- Arduino MKR Series: The Arduino MKR series is a family of boards designed for IoT applications. These boards combine the SAMD21 microcontroller with various wireless connectivity options, such as Wi-Fi, Bluetooth, and LoRa, making them ideal for creating connected projects.
- Adafruit Feather M0: The Adafruit Feather M0 is a lightweight and versatile board that combines the SAMD21 with a LiPo battery charger and various connectivity options, making it perfect for wearable and portable projects.
Board Name | Flash Memory | SRAM | Key Features |
---|---|---|---|
Arduino Zero | 256 KB | 32 KB | Native USB, Compact size |
Arduino MKR WiFi 1010 | 256 KB | 32 KB | Wi-Fi connectivity, Crypto Authentication |
Adafruit Feather M0 | 256 KB | 32 KB | LiPo battery charger, Lightweight design |

Getting Started with the SAMD21
Setting Up the Development Environment
To start developing with the SAMD21, you’ll need to set up your Arduino Integrated Development Environment (IDE) to support SAMD21-based boards. Follow these steps:
- Download and install the latest version of the Arduino IDE from the official Arduino website.
- Open the Arduino IDE and navigate to “File” > “Preferences.”
- In the “Additional Boards Manager URLs” field, paste the following URL:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
- Click “OK” to save the preferences.
- Go to “Tools” > “Board” > “Boards Manager.”
- Search for “SAMD” in the search bar and install the “Arduino SAMD Boards” package.
- Once the installation is complete, you can select your SAMD21-based board from the “Tools” > “Board” menu.
Programming the SAMD21
Programming the SAMD21 using the Arduino IDE is similar to programming other Arduino boards. However, there are a few differences to keep in mind:
- Pin Mapping: The SAMD21 has a different pin mapping compared to classic Arduino boards. Make sure to consult the pinout diagram for your specific board when referencing pin numbers in your sketches.
- Libraries: Some libraries designed for 8-bit Arduino boards may not be compatible with the SAMD21. When using third-party libraries, ensure they support SAMD21-based boards or look for alternative libraries specifically developed for the SAMD21.
- Debugging: The SAMD21 supports debugging through the Serial Wire Debug (SWD) interface. You can use tools like Atmel Studio or OpenOCD to debug your sketches and gain deeper insights into your code’s execution.

Example Projects Using the SAMD21
To showcase the capabilities of the SAMD21, let’s explore a couple of example projects that highlight its features and performance.
Project 1: Capacitive Touch Piano
In this project, we’ll create a simple piano using the SAMD21’s Peripheral Touch Controller (PTC). The PTC allows us to detect touch inputs on conductive surfaces, such as aluminum foil or copper tape.
Materials Required
- SAMD21-based Arduino board (e.g., Arduino Zero)
- Conductive material (e.g., aluminum foil or copper tape)
- Resistors (1 MΩ)
- Speaker or buzzer
- Jumper wires
Step-by-Step Instructions
- Connect the conductive material to the PTC pins on your SAMD21 board. Each piece of conductive material will represent a piano key.
- Connect a 1 MΩ resistor between each PTC pin and ground to provide a reference for the touch sensing.
- Connect a speaker or buzzer to one of the PWM-capable pins on the SAMD21 board.
- Open the Arduino IDE and create a new sketch.
- In the sketch, initialize the PTC library and define the touch threshold for each piano key.
- In the main loop, continuously check the state of each piano key using the PTC library.
- When a touch is detected on a key, generate the corresponding musical note using the tone() function and the connected speaker or buzzer.
- Upload the sketch to your SAMD21 board and start playing your capacitive touch piano!
Project 2: Environmental Monitoring Station
In this project, we’ll create an environmental monitoring station using the SAMD21 and a variety of sensors to measure temperature, humidity, and air quality.
Materials Required
- SAMD21-based Arduino board (e.g., Arduino MKR WiFi 1010)
- Temperature and humidity sensor (e.g., DHT22)
- Air Quality Sensor (e.g., MQ-135)
- OLED display (e.g., SSD1306)
- Breadboard and jumper wires
Step-by-Step Instructions
- Connect the DHT22 temperature and humidity sensor to your SAMD21 board using the appropriate pins.
- Connect the MQ-135 air quality sensor to an analog pin on the SAMD21 board.
- Connect the SSD1306 OLED display to the I2C pins on the SAMD21 board.
- Open the Arduino IDE and create a new sketch.
- Install the necessary libraries for the sensors and display (e.g., Adafruit_DHT, Adafruit_SSD1306).
- In the sketch, initialize the sensors and display, and define the appropriate calibration values for the MQ-135 sensor.
- In the main loop, read the values from the DHT22 and MQ-135 sensors, and calculate the air quality index based on the sensor readings.
- Display the temperature, humidity, and air quality index on the OLED display.
- Upload the sketch to your SAMD21 board and monitor the environmental conditions in real-time!
Frequently Asked Questions (FAQ)
- Q: Can I use Arduino libraries designed for 8-bit boards with the SAMD21?
A: While some libraries may be compatible, it’s best to look for libraries specifically designed for SAMD21-based boards to ensure optimal performance and compatibility. - Q: How does the SAMD21’s performance compare to other Arduino boards?
A: The SAMD21’s 32-bit ARM Cortex-M0+ core and 48 MHz operating frequency provide a significant performance boost compared to 8-bit Arduino boards, allowing you to tackle more complex projects and algorithms. - Q: Can I use the SAMD21 for low-power applications?
A: Yes, the SAMD21 offers several sleep modes that allow the microcontroller to conserve energy when not in use, making it suitable for battery-powered projects and applications that require long-term deployment. - Q: What is the difference between the Arduino Zero and Arduino MKR boards?
A: The Arduino Zero is a general-purpose board that serves as an introduction to the SAMD21, while the Arduino MKR series is designed for IoT applications and includes various wireless connectivity options. - Q: Can I debug my SAMD21 sketches using the Arduino IDE?
A: The Arduino IDE does not provide built-in debugging features for the SAMD21. However, you can use external tools like Atmel Studio or OpenOCD to debug your sketches through the Serial Wire Debug (SWD) interface.
Conclusion
The SAMD21 microcontroller is a powerful and versatile choice for Arduino enthusiasts and embedded systems developers. With its enhanced performance, increased memory capacity, native USB support, and rich peripheral set, the SAMD21 enables you to create more sophisticated and efficient projects.
By exploring the popular SAMD21-based Arduino boards, setting up your development environment, and diving into example projects, you can unlock the full potential of the SAMD21 and take your Arduino projects to the next level.
As you continue to work with the SAMD21, remember to leverage its features, such as the Peripheral Touch Controller and advanced analog peripherals, to create innovative and interactive projects. With the SAMD21 at your disposal, the possibilities are endless!
No responses yet