import cc.arduino.*;
import org.firmata.*;
import processing.video.*;
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
Capture video;
int a = 1024; // width of window
int b = 768; // height of window
int x = 100; // x- position text
int y = 700; // y- position text
int capnum = 0;
int countdowntimer = 10;
int globalframecount = 0;
PImage aj;
PImage bj;
PImage cj;
PImage dj;
color black = color(0);
color white = color(255);
int numPixels;
void setup() {
String portName = Serial.list () [2];
myPort = new Serial (this, portName, 9600);
print(Serial.list ());
frameRate (25);
size(1024, 768); // Change size to 320 x 240 if too slow at 640 x 480
strokeWeight(5);
// This the default video input, see the GettingStartedCapture
// example if it creates an error
video = new Capture(this, width, height, 30);
// Start capturing the images from the camera
video.start();
void draw() {
if ( myPort.available() > 0) {
val = myPort.read();
}
if (val>0) {
globalframecount = 1;
}
println(val);
if (video.available()) {
video.read();
video.loadPixels();
int threshold = 127;
float pixelBrightness;
loadPixels();
for (int i = 0; i<numPixels; i++) {
pixelBrightness = brightness(video.pixels[i]);
if (pixelBrightness > threshold) {
pixels [i] = white;
} else {
pixels[i] = black;
}
}
updatePixels();
int testValue = get(mouseX, mouseY);
float testBrightness = brightness(testValue);
if (testBrightness > threshold) { // If the test location is brighter than
fill(black); // the threshold set the fill to black
} else { // Otherwise,
fill(white); // set the fill to white
}
case ‘t’:
//null
break;
default:
//println(“Zulu”); // Prints “Zulu”
break;
}
if (globalframecount == 25) {
countdowntimer = 9;
}
if (globalframecount == 50) {
countdowntimer = 8;
}
if (globalframecount == 75) {
countdowntimer = 7;
}
if (globalframecount == 100) {
countdowntimer = 6;
}
if (globalframecount == 125) {
countdowntimer = 5;
}
if (globalframecount == 150) {
countdowntimer = 4;
}
if (globalframecount == 175) {
countdowntimer = 3;
}
if (globalframecount == 200) {
countdowntimer = 2;
}
if (globalframecount == 225) {
countdowntimer = 1;
}
// image (video, 0, 0);
if ((globalframecount < 250) & (globalframecount > 0)) {
textFont(fontA, 30);
fill(0);
text (“Preview! Get ready for your photo in “+str(countdowntimer), x+2, y);
text (“Preview! Get ready for your photo in “+str(countdowntimer), x, y+2);
text (“Preview! Get ready for your photo in “+str(countdowntimer), x-2, y);
text (“Preview! Get ready for your photo in “+str(countdowntimer), x, y-2);
textFont(fontA, 30);
fill(255);
text (“Preview! Get ready for your photo in “+str(countdowntimer), x, y);
//text (countdowntimer, width-250, y);
globalframecount++;
}
The project was fun to make and it was something I have never done before.
Working with LED lights is a fun activity and I am planning on furthering my studies on that, as well as on projection mapping.
Next time, I will try to sync the LED lights with the projections to add more of the wow factor to the project. Perhaps, interactivity is also going to be the next step.
There were problems with syphon library in Processing, but it got resolved. The processing part was fairly easy to make, but the next step for me is going to be syncing all three parts (leds, processing, and the clip) together.