Processing Help


#1

Got a question about Processing? Create a new topic and add it to this category!


#2

I moved 2 posts to a new topic: Processing Question


#3

Hey Im trying to play a sound clip in processing whenever a motion detector on my arduino detects motion. My idea is to use the serial port info to detect a value, and in processing use any value greater than 0 to have the sound play once. As of right now the sound plays at the start and never again.

arduino:

boolean motion = 0;

void setup() {
pinMode(8, OUTPUT);
pinMode(7, INPUT);
pinMode(2, OUTPUT);
}

void setup(){
Serial.begin(9600);
}
void loop() {
motion = digitalRead(7);
if(motion == 1){
digitalWrite(8, HIGH);
Serial.println(“1”);

}
else{
digitalWrite(8, LOW);
//Serial.println(“0”);
;
}

}


processing

import processing.serial.;
import ddf.minim.
;

Serial myPort;

String val;

Minim minim;
AudioPlayer song;

void setup() {
String portName = Serial.list()[1];
myPort= new Serial(this, portName, 9600);
minim = new Minim(this);
song = minim.loadFile(“Sound1.wav”, 1024);

}

void draw(){

if ( myPort.available() > 0) {
// If data is available,
//val = myPort.readStringUntil(’\n’);
song.play();

}

}