Pages: [1]   Go Down
Author Topic: Arduino Theremin (with PING sensor)  (Read 1771 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
I recently created an Arduino Theremin using a Parallax PING sensor and a pushbutton.
You can find more info at http://alandtech.blogspot.com/2007/12/arduino-theremin.html.
There's also some videos of me playing Jingle Bells and Tetris.
If you read this and watch the Jingle Bells video before christmas then Merry Christmas!

I'd also like to improve it in some ways: first I'd like to add a second rangefinder for volume control, but I wouldn't know how to lower the speaker volume digitally. Maybe a digital potentiometer? And I would also like to make better sound quality, maybe with a better circuit and PWM to make a sine wave instead of square wave... Anybody knows how I could do this? I heard of using a low-pass filter. Can the Arduino handle higher frequencies to allow me to do that?
If you have any ideas or suggestions, please let me know!

Merry Christmas,
Alberto
http://alandtech.blogspot.com/
Logged


Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To make the sound more "sine wave like" you could try to make a simple lopass filter on the output, just a resistor and a capacitor. You could even use at pot and a capacitor to make an adjustable filter.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Will try that, when I can. And the code would be the same.
But I think that if you want to do more advanced waves, to play music or more than one note at the same time, you would need to do some PWM with a low pass circuit, that would do kindof like that:


But I'm not sure how I could do something similar with the Arduino since it probably isn't fast enough... But maybe there are counters allowing that...
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was looking at this article, and it looks like the Arduino actually does use the ATmega168's timers. Those are used with the PWM pins. That means that when you use the analogWrite() function, it actually uses these timers, so what I said before is probably possible.
Here's what the article says:
Quote
Timers on the Arduino
I contacted David Mellis of the Arduino development team and learned that the library makes use of all three timers on the ATMega168.

    * Timer0 (System timing, PWM 5 and 6)
      Used to keep track of the time the program has been running. The millis() function to return the number of milliseconds since the program started using a global incremented in the timer 0 ISR. Timer 0 is also used for PWM outputs on digital pins 5 and 6.
    * Timer1 (PWM 9 and 10)
      Used to drive PWM outputs for digital pins 9 and 10.
    * Timer2 (PWM 3 and 11)
      Used to drive PWM outputs for digital pins 3 and 11.

I'll try to find out more
Logged


Greenwood, Indiana
Offline Offline
God Member
*****
Karma: 0
Posts: 508
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.uchobby.com/

Three articles about Arduino music, you'll be in 8bit heaven!
Logged

If it was designed by man it can be repaired by man.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I've seen those, but the problem is they use the same technique I use with the theremin, i.e. something like:
Code:
digitalWrite(soundPin, HIGH);
delayMicroseconds(period/2);
digitalWrite(soundPin, LOW);
delayMicroseconds(period/2);
to generate sound, which is ok, but is quite restricted.
But the article I linked to, which is the next one in the series - Arduino Interrupts - explains how to generate sound with a more advanced technique, which is using the built in timers/counters. And they say they'll write new articles on sound using this, so we'll just hope it's coming soon!
Logged


Pages: [1]   Go Up
Jump to: