Skip to content

Instantly share code, notes, and snippets.

@sdbakker
Created September 1, 2014 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdbakker/f89b8ca735c6d7b023bd to your computer and use it in GitHub Desktop.
Save sdbakker/f89b8ca735c6d7b023bd to your computer and use it in GitHub Desktop.
WdKA RFID Workshop Mifare RFID movie trigger gist
/*
* @title: WdKA RFID Workshop Mifare RFID movie trigger gist
* @author: Simon de Bakker <simon@simbits.nl>
*/
import processing.serial.*;
import processing.video.*;
Serial myPort;
String[] UIDs = {
"482818799",
"419918016215050128",
"193763787",
"196111177137"
};
final int NUM_MOVIES = 2;
Movie[] movies = new Movie[NUM_MOVIES];
String[] moviePaths = {
"testmovie1.mp4",
"testmovie2.mp4"
};
Movie currentMovie = null;
void setup() {
size(640, 480);
// List all the available serial ports in the output pane.
// You will need to choose the port that the Wiring board is
// connected to from this list. The first port in the list is
// port #0 and the third port in the list is port #2.
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
for (int i=0; i<moviePaths.length; i++) {
if (i >= movies.length)
break;
movies[i] = new Movie(this, moviePaths[i]); // Load the movie into the program
}
currentMovie = movies[0];
}
void draw() {
background(0);
image(currentMovie, 0, 0, 640, 480);
}
void serialEvent(Serial myPort) {
// read the serial buffer:
String uid = myPort.readStringUntil('\n');
if (uid != null) {
uid = trim(uid);
println("'" + uid + "'");
for (int i=0; i<UIDs.length; i++) {
if (uid.equals(UIDs[i])) {
if (i < movies.length) {
currentMovie.stop();
currentMovie = movies[i];
currentMovie.loop();
}
}
}
}
}
void movieEvent(Movie m) {
m.read();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment