9/16/2008

tickle me!





video

code in arduino:

int switchPin = 3; // assign a pin for the switch
int LEDPin = 13; // select the LED pin
int state = 0;

void setup() {
//initialize the serial
Serial.begin(9600);
pinMode(switchPin, INPUT); // declare the switchPin as an INTPUT
pinMode(LEDPin, OUTPUT); // declare the ledPin as an OUTPUT
}

void loop() {
state = digitalRead(switchPin);
digitalWrite(LEDPin,state);
Serial.print(state,BYTE);
}

code in processing:
import processing.serial.*;
import pitaru.sonia_v2_9.*;

Sample mySample;
Serial myPort;
int inByte;

void setup(){
println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 9600);
// size(50,50);
Sonia.start(this); // Start Sonia engine.
mySample = new Sample("giggle.wav");

//inByte=1;
}

void draw(){
if(inByte==1){

println(" playing");
if(!mySample.isPlaying()){
mySample.setVolume(20);
mySample.repeat();

}
}
else{
println("no playing");
// if(mySample.isPlaying()){
mySample.stop();
// }
}

}

// background(255);
/*
if(mySample.isPlaying()){
background(0,40,0);
}
*/




void serialEvent(Serial myPort){
// while(myPort.available()>0){
inByte = myPort.read();
println(inByte);
}



// Safely close the sound engine upon Browser shutdown.

public void stop(){
//Sonia.stop();
myPort.stop();
super.stop();


}

No comments: