Created
September 2, 2014 13:16
-
-
Save sdbakker/4d8b4b68be367f268fe0 to your computer and use it in GitHub Desktop.
rfid_trigger_movies_simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @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" | |
}; | |
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); | |
currentMovie = null; | |
} | |
void draw() { | |
background(0); | |
if (currentMovie != null) { | |
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 + "'"); | |
if (currentMovie != null) { | |
currentMovie.stop(); | |
} | |
if (uid.equals("482818799")) { | |
currentMovie = new Movie(this, "testmovie1.mp4"); | |
currentMovie.loop(); | |
} else if (uid.equals("419918016215050128")) { | |
currentMovie = new Movie(this, "testmovie2.mp4"); | |
currentMovie.loop(); | |
} else if (uid.equals("193763787")) { | |
currentMovie = new Movie(this, "testmovie1.mp4"); | |
currentMovie.loop(); | |
} else if (uid.equals("196111177137")) { | |
currentMovie = new Movie(this, "testmovie2.mp4"); | |
currentMovie.loop(); | |
} else { | |
currentMovie = new Movie(this, "testmovie1.mp4"); | |
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