Also, I have a new problem now (The end its in sight .... but I'm not quite there yet!)
At the moment the code looks like this:
import processing.serial.*;
import cc.arduino.*;
import ddf.minim.*;
Minim minim, minim2;
AudioPlayer player1, player2;
int ambient;
int photocellPin1 = 0;
int photocellPin2 = 1;
Arduino arduino;
void setup() {
println(arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 57600);
size(512, 200);
minim = new Minim(this);
player1 = minim.loadFile("saxo.mp3", 2048);
player2 = minim.loadFile("marcus_kellis_theme.mp3", 2048);
}
void draw() {
int photocellReading1 = arduino.analogRead(photocellPin1);
int photocellReading2 = arduino.analogRead(photocellPin2);
if(ambient == 0) ambient = arduino.analogRead(photocellPin1);
if (photocellReading1 < ambient-100) {
if(player1.isPlaying()) {
}
else {
player1.play(0);
}
}
else {
if(player1.isPlaying()) {
player1.pause();
player1 = minim.loadFile("saxo.mp3", 2048);
}
}
println("Pin 1 = " + photocellReading1);
println("Ambient = " + ambient);
delay(10);
}
void stop()
{
player1.close();
player2.close();
minim.stop();
super.stop();
}
As you can see, I'm going to have more than one LDR (ten in fact), but I'm not sure how to get 'ambient' to pick up a reading for each pin. Again, I'm sure this is probably easy ..... but not for a newbie! I've tried experimenting with various things all morning, but to no avail I'm afraid. Help would be greatly appreciated!
Thanks