Serial communication and jitter video

PIERPAOLO FERLAINO's icon

Hi,
I'm a newbie and I'm trying to make a video start and play as long as I receive input from a touch sensor.
As long as someone touches the sensor, the video plays. As soon as the sensor remains untouched the video goes black.
My sensor is wired to an arduino board and sends messages via serial communication. It sends 0 if the sensor is not touched, and 1 as long as the sensor is touched.

Normally I would use a conditional statement but I don't understand how this works in jitter.
I used a select object but my serial port continuously listens to messages so it keeps banging my read message. I want to bang only when the value changes from 0 to 1 and then bang again only when the value changes back to 0.

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

Any help is appreciated.

Rob Ramirez's icon

check out the "change" or "togedge" objects

PIERPAOLO FERLAINO's icon

Nice!
Change did the job!

Thank you!