Instructables
Picture of Arduino Optical Theremin
When I first became aware of Arduino, a theremin seemed like a natural project: sensor + actuator.  It turned out to be quite affordable and fun to make.  It is a naive design, using just one photocell and some hacked headphones.  After some experimentation, I decided that a  self-calibrating function was essential if I wanted repeatable performance in different light levels.  Also, I decided to autotune it using math instead of a lookup table.  To me, the pentatonic tuning is the most pleasant, although this can be adjusted easily to chromatic or other tuning schemes if desired.

Here's a list of the materials I used:

* Arduino Uno (running on Mac OS X 10.7.4 Intel)
* USB cable
* Breadboard
* Super-cheap earbud style headphones (from a plane flight, I think)
* standard small photocell
* 10K Ohm resistor
* Some wire
* Soldering gun with solder

Step 1: Hack the headphones

Picture of Hack the headphones
In order to send signals to the headphones, I cut the wires and soldered them to some jumper wires.  There are a few tricky points here. 

First, once you cut the wires and strip off some insulation, you should see 4 wires, 2 from each side.  Each pair forms a circuit with a single headphone.  So we can effectively think of each pair as containing a + wire (usually colored red or blue) and a ground wire (usually copper colored).  We can either just use 1 of the headphones (and thus one of the wire pairs), or we can combine the wires to use both, thereby achieving twice the fun.  To do this, we will want to solder the + wire from each pair together to one jumper wire, and the ground wire from each pair to the other jumper wire.  See detail photo of headphone hack above.

Second, beneath the obvious rubber insulation, there is often a mostly invisible resin layer coating the 4 individual wires.  The easiest way to get it off is to heat it with a lighter until the wires appear to burn briefly.  Note that after this is done, the colors can be very difficult to discern, so it is a good idea to leave a section unburned that you can use to identify them.  I also use a wet cloth to wipe of some of the residue from the burnt resin to improve conduction.

For the actual soldering, I have very primitive equipment, so I just twist the headphone wires together and around the jumper cable and then drip some solder on that.
 
Remove these adsRemove these ads by Signing Up
1-40 of 41Next »
Orange Joe17 days ago

Ha! This is the first thing I thought of making after I made aaaalll of the blinking LEDs. Thanks for a starting point and suggestions for improvements. :-D

Is there anyway to get the theremin to be silent when in darkness, and only produce sound when light is introduced?
You could use a second photoresistor to act as the variable for an condition, putting the main function of the code inside the condition.

Alternatively, loop could be modified as follows:

In place of:

tone(PHONES, f);

use:

if (val > minored) {

tone(PHONES, f);

}

else {

notone(PHONES);

}

(Sorry about the weird linespacing, not sure how to coerce instructables into doing code snippets correctly.

I used your alternative, but I had to change your "minored" to "minread" and capitalize the t in notone (noTone), and then it worked awesome!!

Code Capture.PNG

Yep.... Sorry about the typos. Not sure how the casing got multilated on noTone. I copy/pasted it direct from the code. Probably autocorrect as minored appears to be an autocorrect from minread as well.

trentoa8 months ago

any reason as to why this won't compile on Ubuntu 12.x ? i keep getting errors dealing with double(double)'s etc..

am i missing some libraries/includes it compiles fine in Win 7 environment.

gwarbeh (author)  trentoa8 months ago
No idea. Never used Ubuntu. You could try changing all doubles to floats. I didn't use any special libraries. Good luck.

The errors people are experiencing with the dobule/float issues are because logf is apparently a reserved (or at least used) word in a conflicting namespace in at least some versions of the Arduino IDE.

Renaming this variable to logfreq resolved all errors for me.

mmokhtar2 made it!8 months ago

good circuit ,,, thanks :)

Photo1161.jpg
MoonDocker10 months ago
Fun Stuff! I finally got around to trying this one out. Just like you I had a few pair of the airline headphones and they worked fine. I just used one pair it was hard to distinguish which was + or - but I lucked out and it worked first time around. Thanks for an entertaining afternoon. I am a big fan of Big Bang Theory. I felt like Sheldon while playing with my Theremin!
gwarbeh (author)  MoonDocker10 months ago
Glad you enjoyed it, "Sheldon."
dmartin461 year ago
Does it matter where in the breadboard I plug the wires as long as they are aligned and in the correct holes in the Arduino?
gwarbeh (author)  dmartin461 year ago
Just be sure that you understand the way a breadboard is wired, which holes are connected, etc. If you understand that, then you can hook up the wires however you want, as long as it's equivalent to my circuit. Good luck.
I noticed a couple of people used piezo's with success, I just tried it with a small 8 ohm speaker out of a kid's radio. It works well too.
leeseibert1 year ago
I made a project similar to this. Then I shrunk it down to an ATtiny85 micro controller.

Check it out here:
https://www.youtube.com/watch?v=BsKRtUCCle4
faziefazie1 year ago
I'm done with this project, and this is my first arduino project. Thanks a lot to you :)

if I want to put potentiometer, where should i put? And what kind of potentiometer I should use? thanks before.
gwarbeh (author)  faziefazie1 year ago
Cool. Does it work?
As for the potentiometer (pot), it depends on what you want it to do.

The pot can go in place of the resistor if you want it to affect the volume. A lower resistance will just let more cuurent through to the speaker. Not sure what all types of pots are available, but i'd try one that goes up to 100k; linear is probably fine.

If you put the pot in series with the photocell but before the A0 read, it could be used to affect pitch. You'd wanna use one with a max resistance similar to that of your photocell.
Good luck!
faziefazie1 year ago
I want to try this cool project, but I'm a beginner in Arduino, for Step 3: Write the code, we're just have to write the code in sketch and that's it, or we have to do the step "there are a lot of other things to be done:", because I really don't understand how to do the Variable definitions, Calibration loop, etc. Please help me..
gwarbeh (author)  faziefazie1 year ago
Hi. The code should work as it is. All that about "other things to be done" is just me summarizing what the code is all about. You can just copy the code that I have there as an .rtf if you want. Then you can try fooling around with it to change it and/or learn how it works. Best of luck!
Zetainex1 year ago
(removed by author or community request)
gwarbeh (author)  Zetainex1 year ago
Why not? Give it a try. I don't see how it could break anything. I think the piezo buzzer is probably pretty robust. The frequency response may be an issue, though. It might just make it sound strange. Maybe that's what you want? Good luck, and let me know how it turns out.
I wanted to save me having to use headphones and use a soldering iron and, as I have a piezo buzzer, I wondered if it would work well. The answer is a resounding yes, it sounds almost like your Theremin in the vid. Thanks for the code and the instructions!
Zetainex1 year ago
I wanted to save me having to use headphones and use a soldering iron and, as I have a piezo buzzer, I wondered if it would work well. The answer is a resounding yes, it sounds almost like your Theremin in the vid. Thanks for the code and the instructions!
martzsam1 year ago
I made a video here of mine. I plugged in a regular speaker from a set of desktop speakers. You can't really tell from the video but it does get fuller sound.

http://www.youtube.com/watch?v=Opvzt_hryBE
gwarbeh (author)  martzsam1 year ago
Nice job, martzsam! Sounds good. Thanks for the comment.
Trecool7712 years ago
pretty cool bro. im a master at circuitry and programming but new to microprosessors and the arduino programming language. u look good at all 3.
gwarbeh (author)  Trecool7712 years ago
Thanks Trecool771

I am not a master of any of those, but I do enjoy learning.
AJMansfield2 years ago
I'v actually done stuff with headphones before, and its actually possible to weld the headphone wires with just a regular lighter. I had to do this once when I was in Italy on vacation: I needed a sound cable, and I didn't have access to hardly any of my tools, but fortunately I was able to weld two headphone wires together with that trick and use that.
judas792 years ago
Very cool, have you thought of reversing the way the sensor works, to no light being high frequency sound and low frequency when illuminated by light. Also maybe have the sound cut off at a certain brightness, so its not alway on.
gwarbeh (author)  judas792 years ago
Hi, judas79.
That's a really good idea. I think it will be part of the next version. Thanks.
uncle frogy2 years ago
having built a couple of theremins before I was interested in what this would be like.
I breadboarded a light controlled one as an experiment once, using the basic type of circuit of the classic theremin and oscillators using 555 chips. I never tried using a digital processor.
I personally like the "slide" of the theremin as it allows vibrato
If you adjust the output to line level you could play it through any amp including a home stereo.
also might make an interesting proximity sensor effect like a "party door bell "
great work always push the edges!
uncle frogy
gwarbeh (author)  uncle frogy2 years ago
Thanks, uncle frogy. I like the doorbell idea! It started out with the slide, but I ended up like the step tone thing better.
I can hardly wait to have the time to do this. Just a note though, if you wire up a headphone jack, you can save the ear buds for regular use afterwards.
redrok2 years ago
Hi gwarbeh;

This is only half a Theremin.
A real Theremin has 2 controls, Volume in addition to Frequency.
Basically they worked in a similar way. The volume signal is used to modulate the amplitude of the frequency signal.
I suggest you add a second sensor that controls the pulse width of the frequency output.
redrok
nice project, I'm not a microcontroller fan myself but I may dust off the old arduino and try this. incidentally I made an easy theremin Stripboard layout using off the shelf stuff HERE
hankenstien2 years ago
Nice start have you tried adding more photo resisters to get more sound and or control?
Its something I was going to do, after i built the simple synth that floats around here, and you tube, it would just be changing the pots to photo cells, but you seem to get quite more sound then expected from only one analog input makes me really wonder about the synth with (5 or is it 6?) inputs and what sounds could be achieved.
Anyway cool man nice job!
gwarbeh (author)  hankenstien2 years ago
Thanks, hankenstien.
I have plans to extend the project when I find the time. Yeah, I started off trying to produce waveforms myself and had very poor results. Then I learned about the tone command in Arduino and it was easy. I've recently been trying to combine more that one tone at a time, but that hasn't gotten me anywhere so far. I think if I want more complex sound, I need to learn to create the waveform as an array. There are a couple of sites that explain it. We'll see.
Keigh2 years ago
I had to do a google search for Theramin but now that i have, I'm pretty sure i want one. Maybe you could post a vid of yours working?
gwarbeh (author)  Keigh2 years ago
Hi, Keigh.
There's a link to a youtube vid of mine in the last step. Here it is again:
http://www.youtube.com/watch?v=s6paKXNiuOQ&list=HL1348598591&feature=mh_lolz

Good luck.
1-40 of 41Next »