Project Members: 
Hannes Hesse
Joshua Gomez
Katherine Ahern
Laura Greig
Description:
Let the Sunshine in is a collaborative instrument using light and shadow to create different combinations of sounds. Each player (up to 4) has in their hands a photocell and a flashlight. On the computer, they are correlated as well with a type of drum, and a musical sample. A brief flash of the light across any given photocell triggers a drum beat (so the player is responsible for maintaining the rhythm). A steady light held at full brightness triggers the song sample.
Components:
• 4x photocells, with extra long leads for mobility
• 4x 10K resistors
• 4x flashlights (ideally head mounted ones)
Arduino Code:
int bluePin = 0;
int yellowPin = 1;
int greenPin = 2;
int redPin = 3;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print("B");
Serial.println(analogRead(bluePin));
Serial.print("Y");
Serial.println(analogRead(yellowPin));
Serial.print("G");
Serial.println(analogRead(greenPin));
Serial.print("R");
Serial.println(analogRead(redPin));
delay(1000);
}
Processing Code:
/*
* Let the Sunshine in
*/
import processing.serial.*;
import krister.Ess.*;
String buff = "";
int NEWLINE = 10;
int valB = 0, valY = 0, valG=0, valR=0;
int currentB = 0, currentY = 0, currentG=0, currentR=0;
int lastB = 0, lastY = 0, lastG = 0, lastR = 0;
int threshold = 300;
AudioChannel sunshineB;
AudioChannel sunshineY;
AudioChannel sunshineG;
AudioChannel sunshineR;
AudioChannel beatB;
AudioChannel beatY;
AudioChannel beatG;
AudioChannel beatR;
Serial port;
void setup()
{
size(200, 200);
// Print a list in case COM1 doesn't work out
println("Available serial ports:");
println(Serial.list());
port = new Serial(this, Serial.list()[0], 9600);
// start up Ess
Ess.start(this);
// load accent samples
/*
sunshine_B = new AudioChannel("ceelo.aif");
sunshine_Y = new AudioChannel("aquarius.aif");
sunshine_G = new AudioChannel("blindedByTheLight.aif");
sunshine_R = new AudioChannel("rayOfLight.aif");
*/
sunshineB = new AudioChannel("ceelo.aif");
sunshineY = new AudioChannel("aquarius.aif");
sunshineG = new AudioChannel("blindedByTheLight.aif");
sunshineR = new AudioChannel("rayOfLight.aif");
// load beat samples
beatB = new AudioChannel("kick.aif");
beatY = new AudioChannel("snare.aif");
beatG = new AudioChannel("kick.aif");
beatR = new AudioChannel("snare.aif");
}
void draw()
{
while (port.available() > 0) {
serialEvent(port.read());
}
background(valR, valG, valB);
dropBeats();
}
void dropBeats(){
// if (lastB < threshold && currentB > threshold) {
if(valB<300){
println("BLUE");
beatB.play();
}
// if (lastY < threshold && currentY > threshold) {
if(valY <300){
println("YELLOW");
beatY.play();
}
// if (lastG < threshold && currentG > threshold) {
if(valG<300){
println("GREEN");
beatG.play();
}
// if (lastR < threshold && currentR > threshold) {
if(valR<300){
println("RED");
beatR.play();
}
if(valB > 900){
sunshineB.play(Ess.FOREVER);
}
else sunshineB.stop();
if(valY > 900){
sunshineY.play(Ess.FOREVER);
}
else sunshineY.stop();
if(valG > 1000){
sunshineG.play(Ess.FOREVER);
}
else sunshineG.stop();
if(valR > 900){
sunshineR.play(Ess.FOREVER);
}
else sunshineR.stop();
}
void serialEvent(int serial)
{
// Are you reading data or linebreaks?
if(serial != NEWLINE) {
buff += char(serial);
}
else {
if( "".equals(buff)) {
return;
}
println(buff);
char c = buff.charAt(0); // What player is this data for?
buff = buff.substring(1); // Separate player ID
buff = buff.substring(0, buff.length()-1); // Discard the carriage return at the end of the buffer
lastB = currentB;
lastY = currentY;
lastG = currentG;
lastR = currentR;
// Parse the light value into an integer
if (c == 'B'){
valB = Integer.parseInt(buff);
currentB = valB;
}
else if (c == 'Y'){
valY = Integer.parseInt(buff);
currentY = valY;
}
else if (c == 'G'){
valG = Integer.parseInt(buff);
currentG = valG;
}
else if (c == 'R'){
valR = Integer.parseInt(buff);
currentR = valR;
}
buff = ""; // Clear the value of "buff"
}
}
public void stop() {
Ess.stop();
super.stop();
}