We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Newbie needs help to visualize data from arduino
Page Index Toggle Pages: 1
Newbie needs help to visualize data from arduino (Read 541 times)
Newbie needs help to visualize data from arduino
Sep 27th, 2008, 8:37pm
 
Dear users of Processing.org.
I'm an artist trying to learn and understand processing.org.

I'm new to this kind of programming and so far the only way I get by is by copy/paste code...


I am working on an installation that I want to display a 'water ripple' depending on what part of a surface is pening touched.
For the setup i have a canvas with five piezo microphones attached to it.

I got a Arduino code from Sylvain and Alex from Dorkbot I want to use in this project:

/* Multi-Knock Sensor
* based on
* http://www.arduino.cc/en/Tutorial/Knock
*/

#define SENSORS 3

int ledPin = 13;      // led connected to control pin 13
int knockSensor = 0;  // the knock sensor will be plugged at analog pin 0
int val = 0;         // variable to store the value read from the sensor pin
int statePin = LOW;   // variable used to store the last LED status, totoggle the light
int THRESHOLD = 250;  // threshold value to decide when the detected soundis a knock or not
int triggered = 0;
int state[SENSORS];
int loopCount;
int lastHit;
void resetState(void) {
 int i;
 for (i=0; i < SENSORS; ++i) {
   state[i] = -1;
 }
 triggered = 0;
}

void setup() {
 lastHit = 0;
 resetState();
 pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
 Serial.begin(9600);       // use the serial port
}

void loop() {
 int sensor;
 int hits = 0;
 if (lastHit == 0) {
   for (sensor = 0; sensor < SENSORS; ++sensor) {
     if (state[sensor] != -1) {
       hits++;
     }
     else {
       int val = analogRead(sensor);
       if (val >= THRESHOLD) {
         if(!triggered) {
           triggered = 1;
           loopCount = 0;
         }
         state[sensor] = loopCount;
         hits++;
       }
     }
   }
   if (hits == SENSORS) {
     for (sensor = 0; sensor < SENSORS; ++sensor) {
       Serial.print("sensor ");
       Serial.println(sensor+1);
       Serial.print(" ");
       Serial.println((int) state[sensor]);
       lastHit = 64;
     }
     resetState();
   }
   if (hits > 0) {
     loopCount++;
     if (loopCount > 64) {
       resetState();
     }
   }
 }
 if (lastHit > 0) {
   lastHit--;
 }
}



Now, what I need help with is to show a ripple effect on a given X/Y cordinate on the screen depending on which microphone has the highest signal.

I am supposed to show a mock up model of this by tuesday so help is very much appritiated.


Cheers
Re: Newbie needs help to visualize data from ardui
Reply #1 - Sep 28th, 2008, 10:28am
 
OK. Since it interest me, I searched java ripple effect source on Google and found a page which provides this effect, along with lot of others.
Jerry's Java Image Processing Pages
His Java Image Processing Classes are open source and under the permissive Apache License.
The difficulty here is to get the effect itself out of the Java specific code wrapping Java2D: Processing already does some of this stuff, no need to replicate it.
I believe what you are looking for is the WaterFilter class (download the archive, you will find it in src/com/jhlabs/image).

I don't have time right now to dissect and adapt this to Processing, so perhaps somebody will do before me, or have a solution already at hand.
In all cases, the library above can be useful to many people.
Re: Newbie needs help to visualize data from ardui
Reply #2 - Sep 28th, 2008, 7:21pm
 
Hi all. I'm willing to pay someone for help on this project since i'm totally stuck.
Re: Newbie needs help to visualize data from ardui
Reply #3 - Sep 29th, 2008, 1:17am
 
sent you a message, fellow norwegian

seltar
Page Index Toggle Pages: 1