Project tutorial
Arduino Theremin

Arduino Theremin © LGPL

Arduino Based Theremin with MOZZI Library and LDR

  • 3,738 views
  • 1 comment
  • 5 respects

Components and supplies

Apps and online services

About this project

INTRO


so almost half a year ago, I made this Arduino SYNTH

https://www.hackster.io/Oniichan_is_ded/arduino-atari-punk-synth-2934e8

by using the Mozzi library, which is basically a MIDI audio library for the Arduino Platform.

in this post, I have set up one of its example setup which is an LDR-based theremin, which basically is a pulse modulation setup that utilizes LDR as a Sensor. to sense the light intensity and modulates sound according to that.

Also, thanks to utsource.net to provide components and support for this project, you can check them out if you need to buy cheap and economic electronic components!

MATERIAL REQUIRED

  • Arduino MICRO
  • LDR
  • 10K Resistor 1/4W
  • Speaker
  • Audio Amp (Optional)
  • breadboard
  • jumper wires

SETTINGUP

you can download the Mozzi library from here- https://sensorium.github.io/Mozzi/

the unzip it in the library folder and that's all you need to do.

I used an 8Ohms speaker connected with a PAM8403 audio AMP which is kind of important here because the Arduino's pin cannot output loud sounds because of its low forward current.

if you don't have to then don't worry, just hook a speaker directly with a capacitor in series or make your own amp with NPN Transistor.

Just Connect Speaker Output to D9 of your Arduino

one end of LDR to pin A0 with a 10K Resistance in series with Ground, another end of LDR to 5V.

Upload the given code and power the setup up!

RESULT

Watch the video-



This setup modulates sound according to light intensity, so I used a LAMP as a light source to change the light intensity to get different sounds.

CREEPY SOUND

FURTHERSCOPE/IMPROVEMENT

This doesn't work as an actual theremin but its a really cool concept if you just want to generate some creepy sound.

so I guess in the future I will build a proper theremin which is not really a hard task.

Anyways check out mozzi library, leave a comment if you run into some trouble!

Peace

Code

Theremin COdeC/C++
//#include <ADC.h>  // Teensy 3.0/3.1 uncomment this line and install http://github.com/pedvide/ADC
#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin2048_int8.h> // sine table for oscillator
#include <RollingAverage.h>
#include <ControlDelay.h>

#define INPUT_PIN 0 // analog control input

unsigned int echo_cells_1 = 32;
unsigned int echo_cells_2 = 60;
unsigned int echo_cells_3 = 127;

#define CONTROL_RATE 64
ControlDelay <128, int> kDelay; // 2seconds

// oscils to compare bumpy to averaged control input
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin0(SIN2048_DATA);
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin1(SIN2048_DATA);
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin2(SIN2048_DATA);
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin3(SIN2048_DATA);

// use: RollingAverage <number_type, how_many_to_average> myThing
RollingAverage <int, 32> kAverage; // how_many_to_average has to be power of 2
int averaged;

void setup(){
  kDelay.set(echo_cells_1);
  startMozzi();
}


void updateControl(){
  int bumpy_input = mozziAnalogRead(INPUT_PIN);
  averaged = kAverage.next(bumpy_input);
  aSin0.setFreq(averaged);
  aSin1.setFreq(kDelay.next(averaged));
  aSin2.setFreq(kDelay.read(echo_cells_2));
  aSin3.setFreq(kDelay.read(echo_cells_3));
}


int updateAudio(){
  return 3*((int)aSin0.next()+aSin1.next()+(aSin2.next()>>1)
    +(aSin3.next()>>2)) >>3;
}


void loop(){
  audioHook();
}

Schematics

SCH without AMP
Without tz1va3seip
SCH with AMP
Withamp dpxsxpbkeh

Comments

Similar projects you might like

LED Tower

Project tutorial by Arnov Sharma

  • 5,662 views
  • 0 comments
  • 16 respects

DIY NanoLEAF

Project tutorial by Arnov Sharma

  • 6,061 views
  • 1 comment
  • 12 respects

Arduino Game Controller

Project tutorial by Arnov Sharma and Arnov Sharma

  • 13,243 views
  • 5 comments
  • 18 respects

"UVC Box" a DIY UV Sterilizer

Project tutorial by Arnov Sharma

  • 6,129 views
  • 4 comments
  • 16 respects

HID Volume Knob with Pro Micro

Project tutorial by Arnov Sharma

  • 7,940 views
  • 1 comment
  • 9 respects

I2S Theremin

Project tutorial by Arduino_Genuino

  • 26,964 views
  • 3 comments
  • 27 respects
Add projectSign up / Login