How to let RFID in Arduino play movies in max ?

JQQ's icon

I am trying on a project using the arduino FRID Rc522 as my sensor to play some videos in max , so my problem was how to play the different videos when detecting the different tags.Then the videos will be play in on iPad.

Source Audio's icon

Usually providing more infos about the project and
platform used helps to get any help in the forum.

Liang's icon

i will do the "if else" parts in arduino, and send different lables to Max by serial communication.
different FRIDs ----- arduino control (if else )------ serial port (Serial.println)------ max (serial) ------ max (jitter) bang A B C... different videos.

JQQ's icon

yup i have done the "if else"but then I don't know how to let the max connect to the videos as this my first time using max msp.So is there any tutorials or example for me to create the bang?

below was what i have tried ,but then i was wondering what's next and am I doing the right steps?

Source Audio's icon

Why so complicated ?
Arduino could send just one number for each rfid, and that could trigger videos.
if (CONTENT.SUBSTRING(1) == "D6 62 20 7E" ) Serial.println(0);
if (CONTENT.SUBSTRING(1) == "17 D5 90 EC" ) Serial.println(1)

there is no need for else statemants
And don't print anything else to serial port, just the IDs.

In max You could use autopoplated umenu like this :

Max Patch
Copy patch and select New From Clipboard in Max.

Or use sel 0 1 2 3 4 etc to trigger whatever

JQQ's icon

ok i will try it thanks for help

JQQ's icon

i got another question---
can i use the different arduino button to continue connect with the video and pause it?

Source Audio's icon

what do You mean by different button ?
different from what ?

Source Audio's icon

maybe You mean in addition to rfid ?
You could assign some number that is not in use by rfid. like
if button is pressed : Serial.println(10);
sel 10 in max could than be used to toggle video playback,
I mean to stop and start

JQQ's icon

this might be more clear for u to understand my process of the project.
my problem was listed below
and I was wondering can I just combine these two arduino boards into one board or make it two will be more easier ?

Source Audio's icon

1- I have no iPad, so can't help You with iPad stuff
2- Don't use 2 arduinos and 2 serial ports.
Make different ID for the play / pause button, like
for example 100.

jit.movie does not understand pause and resume, only start and stop

3- why print ?
and how should max know that printer finished printing ?
I would save captured frame as a picture and than deal
with the files later.
Here is example patch :

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

And button should print to serial ONLY when
state changes.
That can be done using bounce library or
coding that manually.
For example
If button were on pin 12 :

int BUTTON; // current state of the button
int exBUTTON; // previous state of the button

void setup() {
pinMode(12, INPUT_PULLUP);
Serial.begin(9600);
}

void loop() {BUTTON = digitalRead(12);
if (BUTTON == HIGH) {exBUTTON = 1;}
if (BUTTON == LOW and exBUTTON == 1) {Serial.println(100); exBUTTON = 0;}
delay(50);
}
Momentary switch should be connected between pin 12 and ground.
One can use analog inputs as well if digital ones are all used for other things

Source Audio's icon

P.S. check the new uploaded arduino button sketch,
I forgot to put some delay in the loop

Source Audio's icon

One more thing - video frame can be captured on the fly
without stoping the playback, it would store the file to disk in the background.

Liang's icon

you can try this patch with the serial part, it is easy to println 1, 2 or 3, from arduino to max,

and [sel 1 2 3] check the number if [change] then bang A B C

here i use keyup to triggle different video, it is a really simple case here, by [switch]

Max Patch
Copy patch and select New From Clipboard in Max.