Gabriella Levine

ongoing and past work

Crepuscule


This shows a video with the effect I want using the mouse – as the mouse scrolls from left to right, the lion walks backwards away from you slowly, until he stops altogether. Then he begins to walk towards you until it gets too blurry to see.


This is a video of images of my mouse and rabbit. The mouse scrolling across the screen achieves the desired effect.


This video shows the circuit for the ultrasonic range finder. At first I was using face detection to determine the distance of the viewer but I decided to use an ultrasonic range finder instead. I think it is a little more accurate at far distances, and sometimes face detection wouldn’t detect me if I had glasses on.

Below, I show the code that I use

This is the code to use a mouse to get the effect I want with a video – a dark animal approaches you, and as you walk towards it, it begins to walk backwards, then when you get very close it gets very blurry.

import processing.video.*;
float changer = 1;
Movie myMovie;

void setup() {
size(640, 480, P2D);
background(0);
// frameRate(10);
// Load and play the video in a loop
myMovie = new Movie(this, “lionTimeFCP.mov”);
// myMovie.loop();//play around with taking this out??
myMovie.speed(1);
myMovie.play();
}

void draw() {
// tint(255, 20);

// image(myMovie, 20,20,width-20,height-20);

/*
if (myMovie.time() > 10)
{
println (“slowing down”);
myMovie.speed(0.25);
}
*/
// background(0);
myMouse();
//myMovie.pause();

//screen res smaller
//codec 64
}

void movieEvent(Movie myMovie) {
myMovie.read();
}

void myMouse() {
//as scroll across the screen, movie changes depending on mouse
float myMouse2 = map(mouseX, 0,width, 0,30);//map mouseX to 30 seconds of movie
//display a certain image depending on the position of the mouse

//println(myMouse2);

float movieSpeed = map(mouseX,0,width, -2,2);
if (mouseX<0) {mouseX = 0;} if (mouseX>width)
{mouseX = width;}
myMovie.speed(movieSpeed);

float movieScale = map(myMovie.time(), 0,10.5, 1.3,1) ;
//println(movieScale);
float tintMovie = map(mouseX, width,0,20,250);
//println(tintMovie);
scale(movieScale);

imageMode(CENTER);
tint(255,tintMovie);

float xpos = 0;
if(movieSpeed<1){ changer = changer -0.5;} if(movieSpeed>1){
changer = changer+0.5;}//instead of this increase steadily, do it instead increase with
//movieSpeed.

xpos = xpos + changer;

image(myMovie, width/2+xpos, height/2,width,height);
println(changer);

if( myMovie.time()<0.1){ myMovie.jump(10.4); changer = 0.5;} if( myMovie.time()>10.4){
myMovie.jump(0.1);
changer = 0.5;
xpos = width/2;}
//println(myMovie.time());
}

Here is the code with the ultrasonic sensor

import processing.video.*;
import processing.serial.*; // import the Processing serial library
Movie myMovie;
Serial myPort;
float xpos, ypos;

boolean firstContact = false;//

void setup() {
size(640, 480, P2D);
background(0);
// Load and play the video in a loop
myMovie = new Movie(this, “MouseSlightBlur1.mov”);
myMovie.loop();//play around with taking this out??
myMovie.speed(1);
// myMovie.pause();
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(‘\n’);
}

void draw() {
// tint(255, 20);

// image(myMovie, 20,20,width-20,height-20);

/*
if (myMovie.time() > 10)
{
println (“slowing down”);
myMovie.speed(0.25);
}
*/
myMouse();
//myMovie.pause();

//screen res smaller
//codec 64
}

void movieEvent(Movie myMovie) {
myMovie.read();
}

void serialEvent(Serial myPort) {
String myString = myPort.readStringUntil(‘\n’);
if (myString != null) {

myString = trim(myString);
// if you haven’t heard from the microncontroller yet, listen:
if (firstContact == false) {
if (myString.equals(“hello”)) {
myPort.clear(); // clear the serial port buffer
firstContact = true; // you’ve had first contact from the microcontroller
myPort.write(‘A’); // ask for more
}
}
// if you have heard from the microcontroller, proceed:
else {
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
// print out the values you got:
// for (int sensorNum = 0; sensorNum < 1; sensorNum++) { // println("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); println("sensor[0] = " + sensors[0]); // add a linefeed after all the sensor values are printed: // println(); fill(100); // if (sensors.length > 1) {

if (sensors[0]<300) { ypos = map(sensors[0], 0,300,0,100); } else if (sensors[0]>2000 && sensors[0]<4300) {ypos = map(sensors[0],2000,4300,100,255); } //ypos = constrain(ypos, 0,2500); xpos = xpos +1; if(xpos>width)
{xpos = 0;}
//ellipse(xpos, ypos, 2,2);

println(ypos);

//ypos = map(sensors[1], 0,1023,0,height);
// fgcolor = sensors[2] * 255;
}
}
// when you’ve parsed the data you have, ask for more:
myPort.write(“A”);
}
void myMouse() {
//as scroll across the screen, movie changes depending on mouse
float myMouse2 = map(mouseX, 0,8000, 0,30);//map mouseX to 30 seconds of movie
//display a certain image depending on the position of the mouse

//println(myMouse2);
background(0);
float movieSpeed = map(ypos,0,255, -2,2.5);
myMovie.speed(movieSpeed);

float movieScale = map(ypos, 0,255, 0.5,1.5) ;//255/2?
println(movieScale);

float tintMovie = map(ypos, 100,0,100,255);

scale(movieScale);
imageMode(CENTER);
tint(255,tintMovie);
image(myMovie, width/2, height/2,width,height);
//println(movieSpeed);

// myMovie.jump(myMouse2);

// myMovie.jump(myMouse);

}

here is the arduino code for programming the sensor and sending the info to processing

int ultraSoundSignal = 7; // Ultrasound signal pin
int val = 0;
int ultrasoundValue = (ultrasoundValue);
int timecount = 0; // Echo counter
int ledPin = 11; // LED connected to digital pin 13
int ledPin2 = 10; // LED connected to digital pin 13
int brightness = 0;
int brightness2 = 0;
int i = 0;
int newBrightness=0;
int newBrightness2=0;
int thisPitch=0;

void setup() {
Serial.begin(9600); // Sets the baud rate to 9600
pinMode(ledPin, OUTPUT); // Sets the digital pin as output
establishContact();
}

void loop() {
timecount = 0;
val = 0;
pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output

/* Send low-high-low pulse to activate the trigger pulse of the sensor
* ——————————————————————-
*/

digitalWrite(ultraSoundSignal, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(ultraSoundSignal, LOW); // Holdoff

/* Listening for echo pulse
* ——————————————————————-
*/

pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
val = digitalRead(ultraSoundSignal); // Append signal value to val
while(val == LOW) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignal);
}

while(val == HIGH) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignal);
timecount = timecount +1; // Count echo pulse time
// Serial.println(val);

}

/* Writing out values to the serial port
* ——————————————————————-
*/
//Serial.println(ultrasoundValue);
ultrasoundValue = timecount; // Append echo pulse time to ultrasoundValue

//Serial.write(“A”); // Example identifier for the sensor
// Serial.print(ultrasoundValue);
// Serial.write(10); //ascii putting code to new line and then hitting hard return
Serial.write(13); //certain things you can only control serially. huge dispays, radios.
//serial is a protocol. game control stuff, old mouses and joysticks

/* Lite up LED if any value is passed by the echo pulse
* ——————————————————————-
*/
Serial.println(ultrasoundValue);
brightness = map(ultrasoundValue,0,4500,0,400);
if(brightness < 20){ analogWrite(ledPin,LOW); // brightness2 = map(ultrasoundValue,0,4500,0,40); //if(brightness < 10){ // int thisPitch = map(brightness, 400, 1000, 100, 1000); // analogWrite(ledPin2,LOW); // tone(13, thisPitch, 2); } newBrightness=map(brightness,0,400,0,255); int thisPitch = map(brightness,0,400,0,2000); analogWrite(ledPin,newBrightness); tone(11,thisPitch,80); newBrightness2=map(brightness,0,400,0,255); analogWrite(ledPin2,newBrightness); //3 pins that say PWM simulates analog fade. fixed or not? //might have to change mapping //might want to say that you have to stay in a certain position. //ut in if statement. if any value is under 230 , turn it off. //map from 230 to 255 //the further away you get, it gets jumpy. //limit the range of interaction? //anything between 230-255 is usable. below should be set to zero. //analogWrite(ledPin, brightness); //Serial.print(newBrightness); // if(timecount > 0){

// digitalWrite(ledPin, HIGH);
// }

/* Delay of program
* ——————————————————————-
*/

delay(10);

}

void establishContact()
{//sends out a msg on startup until it gets a byte of data from Proc.
while (Serial.available()<=0){ Serial.println("hello");//send a starting msg delay(300); } }

Leave a Reply