In an effort to document and archive the circuit and program of the experiencia mistica installation, I publish this circuit and code, in wich a PIR (infrared motion sensor) triggers a display of a RGB LED strip and 2 strobe lights. Additionally has a 12V input and a webcam. It runs in processing with different libraries, such as Arduino, processing.video and minim for the audio
import processing.serial.*;
import cc.arduino.*;
import ddf.minim.*;
import processing.video.*;
import gifAnimation.*;
Minim minim;
AudioPlayer player;
Arduino arduino; //creates arduino object
Capture cam;
Gif tunel;
//variables for PIR
int PIRPIN = 2;
int ledPin = 13;
int counter;
//Variables for RGB strip
int REDPIN= 5;
int GREENPIN= 3;
int BLUEPIN= 6;
int r, g, b;
//Variables for R L strobes
int LEFTPIN =9;
int RIGHTPIN=10;
float leftChannel;
float rightChannel;
float soundValLeft;
float soundValRight;
void setup(){
size(800, 600);
colorMode(HSB);
tunel = new Gif(this, "tunel.gif");
tunel.loop();
cam = new Capture(this, 160, 120);
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(PIRPIN, Arduino.INPUT);
arduino.pinMode(ledPin, Arduino.OUTPUT);
arduino.pinMode(REDPIN, Arduino.OUTPUT);
arduino.pinMode(GREENPIN, Arduino.OUTPUT);
arduino.pinMode(BLUEPIN, Arduino.OUTPUT);
arduino.pinMode(LEFTPIN, Arduino.OUTPUT);
arduino.pinMode(RIGHTPIN, Arduino.OUTPUT);
minim = new Minim(this);
player = minim.loadFile("mystica2.aiff", 1024); //or 2048
player.play();
}
void draw(){
int pirVal = arduino.digitalRead(PIRPIN);
if(pirVal == Arduino.LOW){ //was motion detected
counter ++;
if (counter == 5){ // the sensor has to be triggered at least 5 times to detect strong motion
arduino.digitalWrite(ledPin, Arduino.HIGH);// send the siignal
player.play();
background (255, 0, 0);
//delay(2000);
}
}
if(pirVal == Arduino.HIGH){ //was motion detected
counter=0;
arduino.digitalWrite(ledPin,Arduino.LOW );
background (0, 0, 0);
}
if ( !player.isPlaying() ){
player.rewind();
}
if ( player.isPlaying() ){
for(int i = 0; i < player.bufferSize() - 1; i++) {
soundValLeft= player.left.get(i)*150;
soundValRight= player.right.get(i)*100;
}
int soundintL = int(soundValLeft); // int version of sound value
int soundintR = int(soundValRight);
arduino.analogWrite(LEFTPIN,soundintL);
arduino.analogWrite(RIGHTPIN,soundintR);
cam.read();
image(tunel,0,0);
image(cam, 322, 236);
if (g==255){ // loop for green variation
g=0;}else g++;
tint (g, 255, 255);
if (r==200){ // loop for red variation
r=0;}else r++;
arduino.analogWrite(GREENPIN,g);
arduino.analogWrite(REDPIN,r);
arduino.analogWrite(BLUEPIN,soundintR);
}
}