Skip to content

GuilhermeeMG/Theremin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Arduino MIDI Theremin

A gesture-controlled musical instrument built with Arduino Uno that uses two ultrasonic distance sensors to control note and octave selection, transmitting MIDI data to a Digital Audio Workstation for high-quality sound output.

Features

  • Note selection via right-hand distance from sensor (C, D, E, F, G, A, B)
  • Octave selection via left-hand distance from sensor (octaves 3 through 6)
  • Mode switching via pushbutton
  • RGB LED feedback with colour mapped to the playing note
  • Four operational modes:
    • Normal — single note follows hand position
    • Harmony — plays root note + major third interval
    • Lead Autoplay — plays Hail to the King main riff on loop
    • Chord Progression — plays I-V-vi-IV chord progression on loop

Hardware Requirements

Component Quantity
Arduino Uno 1
HC-SR04 ultrasonic sensor 2
Pushbutton 1
RGB LED (common cathode) 1
220Ω resistors 3
Breadboard 1
Jumper wires several
USB cable 1

Wiring

Sensor 1 — Note selection

HC-SR04 Pin Arduino Pin
VCC 5V
GND GND
TRIG 9
ECHO 8

Sensor 2 — Octave selection

HC-SR04 Pin Arduino Pin
VCC 5V
GND GND
TRIG 7
ECHO 6

Pushbutton

Button Pin Arduino Pin
One leg Pin 10
Other leg GND

RGB LED

LED Pin Arduino Pin Resistor
Red 3 220Ω
Green 5 220Ω
Blue 11 220Ω
GND (longest pin) GND

Software Requirements

The instrument requires four software components to work together:

  1. Arduino IDE — uploads code to the Arduino Download: https://www.arduino.cc/en/software

  2. loopMIDI — creates a virtual MIDI port (Windows) Download: https://www.tobias-erichsen.de/software/loopmidi.html

  3. Hairless MIDI — bridges Arduino serial output to the virtual MIDI port Download: https://projectgus.github.io/hairless-midiserial/

  4. Waveform Free (or any DAW) — receives MIDI and produces audio Download: https://www.tracktion.com/products/waveform-free

Setup

1. Upload the Arduino code

  1. Open theremin.ino in Arduino IDE
  2. Select Tools → Board → Arduino Uno
  3. Select the correct COM port under Tools → Port
  4. Click Upload
  5. Close the Serial Monitor (it will block other programs from using the port)

2. Set up loopMIDI

  1. Open loopMIDI
  2. Type Arduino in the text field at the bottom
  3. Click the + button to create the virtual port
  4. Leave loopMIDI running in the background

3. Set up Hairless MIDI

  1. Open Hairless MIDI
  2. Set Serial Port to the Arduino's COM port
  3. Set MIDI Out to Arduino (the loopMIDI port)
  4. Open File → Preferences and set Baud Rate to 115200
  5. Check Serial <-> MIDI Bridge to activate the connection
  6. The dots between Serial and MIDI should turn green

4. Set up Waveform

  1. Open Waveform Free
  2. Go to Settings → MIDI Devices
  3. Click Scan for new MIDI devices now
  4. Arduino should appear in the list — enable it as Input
  5. Disable Microsoft GS Wavetable Synth to prevent it from playing the default piano sound
  6. Go to Projects, create a new project
  7. Add a new track
  8. Add an instrument plugin to the track (e.g., 4OSC)
  9. Make sure the 4OSC's Mode is set to Poly (required for Harmony Mode)
  10. Click the record arm button (red circle) on the track to enable input monitoring

Running the Instrument

  1. Make sure all four programs are running:
    • Arduino code uploaded (Serial Monitor closed)
    • loopMIDI running
    • Hairless MIDI connected (green dots)
    • Waveform Free with the track armed
  2. Move your right hand in front of the note sensor to change notes
  3. Move your left hand in front of the octave sensor to change octaves
  4. Press the foot switch to cycle through modes

Mode Cycle

Normal → Harmony → Lead Autoplay → Chord Progression → Normal → ...

Mode Sensors Description
Normal Active Single note follows hand position
Harmony Active Root + major third interval
Lead Autoplay Disabled Plays Hail to the King riff
Chord Progression Disabled Plays C–G–Am–F chord loop

Troubleshooting

No sound at all:

  • Check that Hairless MIDI shows green dots (connection active)
  • Make sure the track in Waveform is armed for input (red record button)
  • Verify Microsoft GS Wavetable Synth is disabled
  • Test audio output by clicking the piano keyboard at the bottom of Waveform

Sensors not responding:

  • Confirm wiring is correct (especially VCC and GND on both sensors)
  • Use the Serial Monitor at 115200 baud to print sensor values for debugging

Cannot upload — "COM port access denied":

  • Close Hairless MIDI before uploading
  • The serial port can only be used by one program at a time

Harmony Mode only plays one note:

  • Confirm 4OSC is set to Poly mode, not Mono
  • Make sure the Voices parameter is at least 4

RGB LED not lighting up:

  • Confirm the LED is common cathode (longest pin to GND)
  • Check that resistors are connected to each color pin
  • If common anode, the longest pin should connect to 5V and the code logic will be inverted

Authors

Guilherme Marques Gonçalves — 2022214538
Nuno Pinto — 2022214002

Universidade de Coimbra — Tecnologias de Interface

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages