This project is a really easy and straightforwarding excercise for music lovers, makers and sensors fanatics. What we did is simply emulate a Theremin, a really Iconic musical instruments, with PureData, UDOO and an Arduino Sketch. To detect the movement of the hand, which is going to affect the sound modulation of our Theremin, we used a IR Ping sensor. So, let's start! First we connect the IR sensor to Udoo. Then, we create, compile and upload the Arduino Sketch: Code: int IRpin = A0; int distance = 0; int msg = 0; void setup() { // put your setup code here, to run once: Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: distance = analogRead(IRpin); if (distance < 100) { distance = 100; } else if (distance > 900){ distance = 900; } msg = map(distance, 100, 900, 0, 255); Serial.write(msg); } What this does is basically send as analog serial measurements, the distance from it from our hands, and sends the data via serial port. It works within a range from 0 to 255, and ideally it works best detecting our hands in a distance ranging from 4 to 30 centimeters. We then set up PureData, which is going to hook to serial /dev/ttymxc3 via comport, an external which enables PureData to handle serial port communications. And set up appropriately. This was our result, fell free to experiment with it and add more channels! When everything is set up, just launch PureData's DSP, and enjoy your brand new digital Theremin! You can download the Arduino Sketch and the PureData project here http://www.udoo.org/wp-content/uploads/2014/01/UDOO_theremin.zip
Just curious, I am sort of a novice with Arduino programming. If I wanted to use another sensor capable of analog input instead of the IR, say a potentiometer, how would I change the Arduino code? I am assuming that the PD sketch would remain the same. thank you in advance for any help. Nick
The same code would work quite fine with most sensors. Assuming the sensor is analog and outputs voltage the code would be quite the same, the only difference is that you probably can skip the <100 >900 part or modify the values to reflect your sensor. If you use a potentiometer, you wìll probably get values between 0 and 1023 for the input, there is no need to cut the lowest 100 (<100) or the upper 100 (>900), or you may want to make the "cut" minimal (like <10 and >1013). The best thing is to connect the sensor and print out its max an min values to Arduino IDE Serial Monitor Using Serial.begin(<speed>) and Serial.witeln(analogRead(IRpin)). This way, moving your potentiometer/using your sensor you can get an idea of its range of values. Then use the measured values instead of 100 and 900 in the code. Code: int sensorMin=5; // or 0 // test with Serial.writeln(distance) to print minimum value of your sensor to Serial Monitor int sensorMax=1018; // or 1023 // test with Serial.writeln(distance) to print maximum value of your sensor distance = analogRead(IRpin); // not really "distance" anymore, not really an IR pin anymore... // just kept the names from original code if (distance < sensorMin) { distance = sensorMin; } else if (distance > sensorMax) { distance = sensorMax; } msg = map(distance, sensorMin, sensorMax, 0, 255);
francescomm thank you for your reply. I'm having a problem getting this project going. I uploaded my arduino code. I tested my potentiometer with Serial.println and that seems to be working. Then I put it back to Serial.write and I tried out the pd patch. I am doing Serial.begin(9600); In pd, when I press the devicename /dev/ttymxc3 message I get this in the pd window: [comport] no serial devices found for "dev/tty[ASU]*" Is my pd not setup to talk to the arduino ports or something? Any help would be greatly appreciated. thanks, Nick
OK, so I read in another post how to open the serial connection. In pd you create a button object, connect it to the message object with "devicename /dev/ttymxc3" in it, then press the button. That seems to open the connection. I am still not getting any values out of the comport object, but I'm going to keep working on it. Nick
Hello There, I'm new with Pd and need to use it for an interactive installation that should run without a computer (I mean, without a big and costly one). I got a couple a UDOO Dual, installed UDOObuntu and works perfect, it was a pleasant surprise that Pd and Arduino IDE were already installed. Very nice work guys! I ran a basic sketch on Arduino and every thing works fine, then I tried to reproduce this project that it's just what I needed to start but I couldn't get Pd working, With ALSA drivers an: "Audio I/O error" ocurred, if I tried to select another audio driver already installed (OSS, portaudio, jack) any of them can start successfully. I'm neither a Linux nor Pd savvy, any recommendation will be much appreciated. Thanks UDOOers. Javier