Archive by Author

Final Project – Soundbox of Light – Charlene Kulesa

19 Dec

IMG_1670 IMG_1675 IMG_1694

My project is an interactive installation that tracks light intensity and correlates that data to a specific musical note. Movement is a secondary and indirect component that impacts the sound as it changes the degree of light intensity that is read by the photoresistor sensors. The base of the “soundbox of light” is a repurposed turntable where the record is raised above the turntable arm and has 4 cutout sections on the record that allow the ambient light to pass through to the photoresistor sensor that is attached to the turntable arm. The code is written so that if the light intensity is greater than 500, and the push button for the turntable is turned on, that it will play note 20 (reference the Midi Note Chart for the specific musical note). The record is cut so that the cutout sections are all equidistance and therefore when the turntable is turned on the notes are played as a rhythmic background beat.

The laser harp portion was added to the end of the turntable and the frame that houses the 3 lasers has a hinge that allows the frame to either lay down on top of the turntable or positioned upright when being played. The initial intent was to have a tilt switch sensor that turns on and off the lasers but due to inconsistent readings from the tilt switch I had to default to a push button sensor to turn on and off the lasers. Photoresistor sensors were placed at the base of the frame to align with each laser at the top of the frame.

The laser harp code uses both the direct light from the laser and the ambient light of the room to determine the musical note that is played on the laser harp. If the light intensity was less than 900 that meant that there was a break between the laser and its corresponding photo resistor sensor. This was the baseline that determined whether a note should be played. The actual note and pitch being played is based off of the light intensity. This light intensity decreases and increase as the user’s hand gets closer or farther away from the sensor.. The pitch of the note is dependent on the ambient light of the room and therefore the sound can vary from room to room, even though the code is exactly the same. If it is desired to hard code the exact note to be played depending on the height of the hand that is covering the laser, one could add a range detector and hard code a specific note to the hand location. For this project, I preferred the element of the ambient light as an uncontrolled variable that impacted the sound but I also see the benefit of having more control over the sound and note being played regardless of the ambient light.

Here is the code:

#include

// Constant variables:
int LEDpin = 13; // set LED to pin 13
int laserAPin = 10; // set laserA to pin 10
int laserBPin = 11; // setlaserB to pin 11
int laserCPin = 12; // set laserC to pin 12
int buttonTt = 5; // set turntable button to pin 5
int buttonL = 4; // set laser button to pin 4

// Variables for turntable:
int valTt = 0; // set turntable val to 0
int old_valTt= 0; // set turntable old val to 0
int stateTt =0; // set turntable state to 0

// Variables for lasers:
int valL = 0; // set turntable val to 0
int old_valL= 0; // set turntable old val to 0
int stateL =0; // set turntable state to 0

// Variables for notes:
byte noteA = 0; // The MIDI note value to be played for laserA
byte noteB = 0; // The MIDI note value to be played for laserB
byte noteC = 0; // The MIDI note value to be played for laserC
byte noteTt = 0; // The MIDI note value to be played for Turntable

// Variables for analog values:
int AnalogAValue = 0; // value from analog laserA photosensor
int AnalogBValue = 0; // value from analog laserB photosensor
int AnalogCValue = 0; // value from analog laserC photsensor
int AnalogTtValue = 0; // value from analog turntable sensor

// Software serial:
SoftwareSerial midiSerial(2, 3); // digital pins that we’ll use for soft serial RX & TX

void setup()
{
// Set the states of the I/O pins:
pinMode(LEDpin, OUTPUT);
pinMode (laserAPin, OUTPUT);
pinMode (laserBPin, OUTPUT);
pinMode (laserCPin, OUTPUT);
pinMode (buttonTt, INPUT);
pinMode (buttonL, INPUT);

// Set MIDI baud rate:
Serial.begin(9600);
midiSerial.begin(31250);

}

void loop()
{
// Set logic for turning on and off turntable via button:
valTt = digitalRead(buttonTt); // reads input on turntable button
if ((valTt == HIGH) && (old_valTt == LOW)) // check if val has transitioned
{stateTt = 1 – stateTt; // change state from on to off or vice-versa
delay (10); } // set delay

old_valTt = valTt; // val is now old val, store it

if (stateTt == 1) // check to see if state of turntable button is 1 (on)
{digitalWrite (LEDpin, HIGH); } // if true turn on LED
else { digitalWrite (LEDpin, LOW); } // if false turn off LED

// Set logic for turning on and off lasers via button:
valL = digitalRead(buttonL); // reads input on laser button
if ((valL == HIGH) && (old_valL == LOW)) // check if val has transitioned
{stateL = 1 – stateL; // change state from on to off or vice-versa
delay (10);} // set delay

old_valL = valL; // val is now old val, store it

if (stateL == 1) // check to see if state of laser button is 1 (on)
{
digitalWrite (laserAPin, HIGH); // if true turn on lasers A, B and C
digitalWrite (laserBPin, HIGH);
digitalWrite (laserCPin, HIGH);
}
else // if false turn off lasers A, B and C
{
digitalWrite (laserAPin, LOW);
digitalWrite (laserBPin, LOW);
digitalWrite (laserCPin, LOW);
}

// Set up analog read values:
AnalogAValue = analogRead(1);
AnalogBValue = analogRead(2);
AnalogCValue = analogRead(3);
AnalogTtValue = analogRead(5);

// Define note values:
noteA = (AnalogAValue/21); // A top range is approx 790; this equation equals note 36 (C)
noteB = ((AnalogBValue/15)-1); // B top range is approx 810; this equation equals note 51 ( D#)
noteC = (AnalogCValue/12); // C top range is approx 825; this equation equals note 67 (G)
noteTt = (AnalogTtValue/23);

// Logic that determines when and what note is played:
if ((AnalogAValue < 900) && (stateL == HIGH)) // if laserA sensor value is less than 900
{noteOn(0x90, noteA, 0x35);} // then play noteA at medium velocity

if ((AnalogBValue < 900) && (stateL == HIGH)) // if laserB sensor value is less than 900
{noteOn(0x90, noteB, 0x35);} // then play noteB at medium velocity

if ((AnalogCValue 500) && (stateTt == HIGH)) //
{noteOn(0x90, 0x20, 0x45);}

delay (250); // set delay value
}

// plays a MIDI note.
// cmd is greater than 127, or that data values are less than 127:
void noteOn(byte cmd, byte data1, byte data2)
{
midiSerial.write(cmd);
midiSerial.write(data1);
midiSerial.write(data2);

//prints the values in the serial monitor
Serial.print(“A:”);
Serial.print(AnalogAValue);
Serial.print (“, B:”);
Serial.print (AnalogBValue);
Serial.print (“, C:”);
Serial.print (AnalogCValue);
Serial.print (“, Tt:”);
Serial.print (AnalogTtValue);
Serial.print(“, cmd: “);
Serial.print(cmd);
Serial.print(“, data1: “);
Serial.print(data1);
Serial.print(“, data2: “);
Serial.println(data2);
}

Final Project Proposal – Soundbox of Light – Charlene Kulesa

2 Dec

Soundbox of Light    

My project is using both light and movement to create an interactive sound experience by combining elements from a turntable and a harp to create a soundbox of light.  The needle of the turntable is replaced with an LED “needle” and a vinyl record has a pattern of slits cut out from it which allow the light to pass through to the sensor below. The sensor reads the oscillation between dark and light as the record turns which then translates the staccato moments of light into sound.

The harp is a 14” frame that hinges off the backside of the turntable so that the user can interact simultaneously with both the harp and the turntable.  The harp is made of lasers with corresponding light sensors. Each sensor is coded to a specific note, which is played when there is a break between the laser and the sensor. I am also attempting to explore tracking hand movement while it interacts with the laser and use that data to modulate the sound. For example, the pitch of the note will increase or decrease as the hand moves vertically on the laser beam or tracking the velocity of the hand as it initially breaks the laser from the sensor, the higher the velocity the higher the volume.

IMG_1643

Materials:

3-5 lasers, 1 LED, 4-6 photo resistor sensors, tilt switch, range detector sensor (ultrasonic range detector and infrared range sensor), Arduino, breadboard, wires, Max MSP or Midi shield, pine plywood ¼” X 24” X 24” (pack of 4), wood glue, nails, 4 metal hinges, record, extra turntable arm and turntable

Schedule:

Sunday Dec 1st:

– Make adaptations to the turntable

– Create initial code to test basic function of sensors for both the turntable (LED and photo resistor) and laser harp (2 lasers, photo resistors, tilt switch, ultrasonic range detector)

Monday Dec 2nd – Thursday Dec 5th

– Continue working the code by adding sound through Max MSP or Midi Shield and increase the function of the laser harp

  • Laser 1- add logic to the code that determines velocity of the change of light intensity and correlates that velocity to a specific decibel level in which the note of Laser 1 will be played at.

(Example: if a hand slowly blocks the laser the note will be played at a lower volume. If the light is blocked quickly it will be played at a higher volume)

  • Laser 2- test multiple distance sensors and determine best sensor to capture hand location on Laser 2. Add logic to code that will change the pitch that is played by Laser 2 relative to the location of the hand blocking the laser

Friday, December 6th:

– Build container for laser harp and turntable

– Laser cut record for turntable

– Continue working on the code

Saturday, December 7th:

– Wire laser harp and turntable into final container

– Add code for the 2-3 lasers added to the laser harp (Total of 4-5 lasers)

– Test the code on the final product and make necessary tweaks

Sunday, December 8th:

– Continue tweaking the code and make adjustments as needed

Monday, December 9th– Wednesday Dec 11th:

– Buffer days

Homework 05 – Arduino and Processing – Charlene Kulesa

14 Nov

I changed the background color and included a variable for the opacity, which is determined by the y-plane of the mouse. The processing code is determined by the potentiometer.

import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph

void setup () {
// set the window size:
size(1000, 400);

println(Serial.list());// List all the available serial ports
myPort = new Serial(this, Serial.list()[0], 9600); // don’t generate a serialEvent() unless you get a newline character:
myPort.bufferUntil(‘\n’);

background(200); // set inital background:
}
void draw () {

}

void serialEvent (Serial myPort) {// get the ASCII string:

String inString = myPort.readString();

if (inString != null) { // trim off any whitespace:

inString = trim(inString);// convert to an int and map to the screen height:

float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);//map incomming value to height of screen

stroke(0, 128 , 122, mouseY );// draw the line:
line(xPos, height/2, xPos, height – inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(200);
}
else {
// increment the horizontal position:
xPos++;
}
}
}

Homework 03 – Servo Motor Controlled by Variable Resistor – Charlene Kulesa

31 Oct

I used the photoresistor (LDR) to control the speed of the LED lights and the movement of the servo motor. Here is my video and code:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int LDR = 0; // analog pin used to connect the LDR
int val; // variable to read the value from the analog pin
int blue = 3;//setting blue LED variable
int green = 5;// setting green LED variable
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode (blue, OUTPUT);// sets pin 3
pinMode (green, OUTPUT);// sets pin 5
}

void loop()
{
val = analogRead(LDR); // reads the value of the LDR (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(10); // waits .10 sec for the servo to get there
digitalWrite (blue, HIGH); // Turns on the blue light
delay(val); // delay depending on val (LDR)
digitalWrite (blue, LOW); // Turns off the blue light
delay(val); // delay depending on val (LDR)
digitalWrite (green, HIGH); // Turns on the green light
delay(val); // delay depending on val (LDR)
digitalWrite (green, LOW); // Turns off the green light
}

Homework 02- RGB LED Blink with Potentiometer- Charlene Kulesa

29 Oct

I used the Arduino  to create a  sub-loop within the overall loop where the sub-loop increases by one LED each round until all three LEDS are included in the final sub-loop and then the overall loop starts again. The overall delay is controlled by the potentiometer but I created a static hold of .5 seconds after the end of each sub-loop so that there is a visual variance between the sub-loops.

IMG_1613

int red = 3; //setting red led variable  

int blue = 5; //setting blue led variable

int green = 6; //setting green led variable

int pot = 0; //potentiometer

 

void setup() {

pinMode (red, OUTPUT);

pinMode (blue, OUTPUT);

pinMode (green, OUTPUT);

}

void loop() {

  pot = (analogRead(A0));

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(500); // Delay of .5 seconds. End of sub-loop 1

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (blue, HIGH); //Turns on the blue light

delay(pot); // Delay depending on potentiometer

digitalWrite (blue, LOW); //Turns off the blue light

delay(500); //Delay of .5 seconds. End of sub-loop 2

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); //Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(pot); //Delay depending on potentiometer

digitalWrite (blue, HIGH); //Turns on the blue light

delay(pot); //Delay depending on potentiometer

digitalWrite (blue, LOW); //Turns off the blue light

delay(pot); //Delay depending on potentiometer

digitalWrite (green, HIGH); //Turns on the green light

delay(pot); //Delay depending on potentiometer

digitalWrite (green, LOW); //Turns off the green light

delay(500); //Delay of .5 seconds. End of sub-loop 3

}