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.
- 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
| 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 |
| HC-SR04 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | 9 |
| ECHO | 8 |
| HC-SR04 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | 7 |
| ECHO | 6 |
| Button Pin | Arduino Pin |
|---|---|
| One leg | Pin 10 |
| Other leg | GND |
| LED Pin | Arduino Pin | Resistor |
|---|---|---|
| Red | 3 | 220Ω |
| Green | 5 | 220Ω |
| Blue | 11 | 220Ω |
| GND (longest pin) | GND | — |
The instrument requires four software components to work together:
-
Arduino IDE — uploads code to the Arduino Download: https://www.arduino.cc/en/software
-
loopMIDI — creates a virtual MIDI port (Windows) Download: https://www.tobias-erichsen.de/software/loopmidi.html
-
Hairless MIDI — bridges Arduino serial output to the virtual MIDI port Download: https://projectgus.github.io/hairless-midiserial/
-
Waveform Free (or any DAW) — receives MIDI and produces audio Download: https://www.tracktion.com/products/waveform-free
- Open
theremin.inoin Arduino IDE - Select Tools → Board → Arduino Uno
- Select the correct COM port under Tools → Port
- Click Upload
- Close the Serial Monitor (it will block other programs from using the port)
- Open loopMIDI
- Type
Arduinoin the text field at the bottom - Click the + button to create the virtual port
- Leave loopMIDI running in the background
- Open Hairless MIDI
- Set Serial Port to the Arduino's COM port
- Set MIDI Out to
Arduino(the loopMIDI port) - Open File → Preferences and set Baud Rate to 115200
- Check Serial <-> MIDI Bridge to activate the connection
- The dots between Serial and MIDI should turn green
- Open Waveform Free
- Go to Settings → MIDI Devices
- Click Scan for new MIDI devices now
Arduinoshould appear in the list — enable it as Input- Disable
Microsoft GS Wavetable Synthto prevent it from playing the default piano sound - Go to Projects, create a new project
- Add a new track
- Add an instrument plugin to the track (e.g., 4OSC)
- Make sure the 4OSC's Mode is set to Poly (required for Harmony Mode)
- Click the record arm button (red circle) on the track to enable input monitoring
- 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
- Move your right hand in front of the note sensor to change notes
- Move your left hand in front of the octave sensor to change octaves
- Press the foot switch to cycle through modes
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 |
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
Guilherme Marques Gonçalves — 2022214538
Nuno Pinto — 2022214002
Universidade de Coimbra — Tecnologias de Interface