กลับไปหน้ารวมไฟล์
i2s-theremin-ab8e68-en.md

Note: This tutorial could be outdated, please go here for a more current version.

Arduino I2S library

The new Arduino I2S library allows you to send and receive digital audio data on the I2S bus. This example aims to show how to use this library to drive an I2S DAC to reproduce sound computed within the Arduino sketch.

For more information about the library and how it works read the library page.

I2S Connections

The I2S DAC used in this example needs only 3 wires for the I2S bus (plus power supply). Connections for the I2S on the Arduino MKRZero are the following:

  • SD (Serial Data) on pin A6;
  • SCK (Serial Clock) on pin 2;
  • FS (Frame or Word Select) on pin 3;

How it works

A theremin has basically two controls:

  • pitch
  • volume

In this example these two parameters are changed moving two slide potentiometers, but you can modify it to read them using for example a ping sensor! In this way your theremin will be more realistic!

The two potentiometers are wired in a voltage divider fashion, so moving them you will get (from analogRead()) values in the range 0 - 1023. These values are then mapped to between the minimum and maximum frequency and the minimum and maximum volume.

The sound sent on the I2S bus is a simple sine whose frequency and amplitude is changed according to the potentiometers reading.

EXPANDED TECHNICAL DETAILS

High-Fidelity Audio Synthesis

This project builds a professional-grade digital Theremin using high-speed distance sensors and an I2S DAC for superior sound quality.

  • I2S Audio Pipeline: Unlike standard PWM audio, this project uses the I2S (Inter-IC Sound) protocol to stream 16st-bit audio to an external DAC (like the MAX98357A). This eliminates digital noise and provides a clean, sine-wave-like tone.
  • Distance-to-Frequency Algorithm: Uses an ultrasonic sensor or an IR Time-of-Flight (ToF) sensor. The Arduino calculates the pitch based on the distance, utilizing a lookup table for Western musical scales (e.g., Minor Pentatonic).

Visualization

  • Arduino Web Editor Sync: (Specific to this variant) Uses the Arduino IoT Cloud to display the current frequency and volume on a desktop dashboard, allowing for real-time performance visualization.

ข้อมูล Frontmatter ดั้งเดิม

title: "I2S Theremin"
description: "Discover how to make an I2S Theremin based on the new Arduino I2S library."
author: "Arduino_Genuino"
category: "Audio & Sound"
tags:
  - "audio"
  - "maker"
views: 29539
likes: 16
price: 2450
difficulty: "Easy"
components:
  - "1x MAX98357A"
  - "1x Breadboard (generic)"
  - "2x RobotGeek Slider"
  - "1x Speaker: 3W, 4 ohms"
  - "1x Jumper wires (generic)"
  - "1x Arduino MKR Zero"
tools: []
apps:
  - "1x Arduino IDE"
  - "1x Arduino Web Editor"
downloadableFiles:
  - "https://create.arduino.cc/editor/Arduino_Genuino/5574e381-3fe5-4c8f-9877-0dea97ea6ec3/preview"
documentationLinks: []
passwordHash: "8914eb7da47f5148050d70287756caa815058c649ec68c54a91a59f6badf1a29"
encryptedPayload: "U2FsdGVkX1953jgbT1AkmrPgffuZOWsMi2Fc21/J7llHsFDm6g4ooagJtUDvnWevSeF77SzqMA6nJlQVZ2e0Ug73sAEHSuCS2tdRXasyPZFI5W36czO6yXmEqVfSlUJf"
seoDescription: "Learn how to build a DIY I2S Theremin using the latest Arduino I2S library for high-quality digital audio synthesis."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/i2s-theremin-ab8e68_cover.png"
lang: "en"