The OF Portal


By Maarten Lodewijk, Felipe, and Matei





The OF Portal is a door powered by openFrameworks that leads to a randomly selected location each time the door is opened. We came to this idea after we found an abandoned door in the workshop of the university, and decided it was a perfect item to use for a project with the theme "space". We drew some inspiration from the movie Monsters inc., and so our project idea came to be.




Two wires connected to an arduino are embedded in the frame. When the door closes, a closed electrical system is made, which breaks as soon as the door is opened again. When closed, the arduino sends a byte to openFrameworks. Upon receiving a byte, OF will load random movies every 1,5 second until the door is opened again. The last loaded movie will then keep playing until the door is closed.





PICTURES











MOVIE TO BE ADDED

OFAPP.CPP CODE

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
serial.enumerateDevices();
vector deviceList = serial.getDeviceList();

// this should be set to whatever com port your serial device is connected to.
// (ie, COM4 on a pc, /dev/tty.... on linux, /dev/tty... on a mac)
// arduino users check in arduino app....
int baud = 9600;
serial.setup(0, baud); //open the first device
//serial.setup("COM4", baud); // windows example for selecting specific comport
//serial.setup("/dev/tty.usbserial-A4001JEC", baud); // mac osx example for selecting specific comport
//myPlayer.loadMovie("movies/aviao interior.mp4");
myPlayer.loadMovie("movies/testMovie_1.mp4");
myPlayer.setVolume(0.3);
mySound.loadSound("sound/wormhole.wav");
mySound.play();
mySound.setVolume(1.0);
mySound.setLoop(true);
}

//--------------------------------------------------------------
void ofApp::update(){
// If the byte size is bigger than 0 (ignores zeroes coming from the LDR)
if(serial.available() > 0) {
// Read the bytes from serial port
int myByte = serial.readByte();
// No data from serial
if ( myByte == OF_SERIAL_NO_DATA )
printf("no data was read");
// If serial error
else if ( myByte == OF_SERIAL_ERROR )
printf("an error occurred");
// If it actually is working.
else if ( myByte == 50 ){
float ranNumb = ofRandom(1, 27);
int rounded = (int)ranNumb;
cout << rounded << "\n";
//myPlayer.loadMovie("movies/aviao interior.mp4");
myPlayer.loadMovie("movies/testMovie_" + ofToString(rounded)+ ".mp4");
}

else
printf("myByte is %d", myByte);
}
myPlayer.update();
}

//--------------------------------------------------------------
void ofApp::draw(){
myPlayer.draw(0,0,1280, 1024);
myPlayer.play();
}

OFAPP.H CODE

#pragma once #include "ofMain.h" class ofApp : public ofBaseApp{

public:
void setup();
void update();
void draw();

void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

ofSerialserial; // Adds ofSerial class to the project.
ofVideoPlayer myPlayer; //adds videoplayer class to the project
ofSoundPlayer mySound;

};

ARDUINO CODE:

void setup() { Serial.begin(9600); pinMode(A0, INPUT); }

void loop() {
if (analogRead(A0) < 50) {
Serial.write(50);
} else {
Serial.write(100);
//The two wires are disconnected
}
delay(1500);
}