Okay, it’s not exactly musical, but this is a pretty cool quick Arduino project you can make with:
- an LED
- a piezo buzzer
- er, that’s it
Okay, you need an Arduino, but it doesn’t even use a resistor.
I used the code in this project: http://mvartan.com/2013/03/11/1-photo-theramin-and-more-fun-with-reversed-leds/ and removed the push button because I found it worked better with the button always pressed – so I just shorted it out.
I wired up the LED and the buzzer like this:
The important thing is that the LED is wired up back to front – this is what makes it act like a light detector, rather than emitter. You connect the long, positive leg of the LED to ground (GND) and the short, negative leg to Analogue pin 0 (A0).
Connect the positive side of the buzzer to Digital pin 8, the negative side to GND and I just shorted digital pin 7 to GND because I couldn’t be bothered to tweak the code – in the original a push button sits between Digital pin 6 and GND.
Wire it up, upload the code and the closer you move your hand to the LED, the more ambient light gets blocked and the higher the pitch of the note goes.
Oddly, when I tried to film this on my iPhone, the soundtrack was almost entirely silent, though it was really loud in the room – and loud enough on my Fuji X10 still camera. Also, if you touch the negative side of the LED, it goes NUTS!