Arduino Ultrasonic triggering of delayed mirror, explained (Composition by leon)

Author: leon
License: Creative Commons Attribution-NonCommercial-ShareAlike
Date: 2015.06.17
Compatibility: 10.10
Required plugins:
Serial IO

A pupil wanted to make a art installation where a mirror, when approaching, suddenly gave you your same reflection but with a 5 second delay. Here is the patch.

It is hold simple, and with a lot of explaining notes, to help beginners to get into Quartz. It is also an easy connection from the ArduinoSensor-Universe to Quartz. Therefore, it has several optional patches for variating input (keyboard as toggle, Arduino with potentiometer knob) for testing and developing. Inside the patch are the sketches for Arduino (just copy and paste), I attach the wiring-pictures made with Fritzing and the Arduino Library for the Sensor (original link is inside the sketch). There is also an option to avoid using this library.

For beginners: you have to download and install the Serial IO plugin of Kineme in, therefore you have to login (and if necessary register).

I have been helped here in Kineme a lot, and hope this helps somebody else.

Another theme: I see little activity lately. Guess people dedicate themselves to other stuff, also the founding members. Anyway, I think Quartz is still a great platform for info processing with diverse in- and output (despite I use it mainly for live visuals) and still not deprecated by Apple, so, I would love to see a revival….

Swiftlikeninja's picture
Re: Arduino Ultrasonic triggering of delayed mirror, ...

This composition looks very interesting and I will enjoy delving into it. I completely agree on your second note about the community here. There has been a severe down turn in activity on what the community seems to deem as a dead language. If you haven't been to it yet, the Quartz composer Facebook group is still pretty active. I still quite enjoy Quartz and believe in its possibilities. On a slight side note, I did notice some minor changes in quartz in regards to how javascript patches are handled, indicating to me that the program is not 100% off Apples radar. (If (!_TestMode)) no longer works when importing legacy JS code from previous iteration of quartz for example, and in mavericks if you were editing JS, smart quotes (enabled by default)would severely muck things up. Yosemite cleared up that last one.)

Thanks for sharing!


leon's picture

Thank you for your comment, Shayne.

I didn't know about the FB group! gonna look at it right now. One question: My english is not good enough to understand what you meant with not 100% off Apples Radar, unsure if 100% off means it is not outside (as I believe) or not 100% part of = deprecating? The test mode not working (I never used JS, still have to learn that) is good or bad, the second action seems to mean a debugging? Sorry my ignorance, sometimes I get to my limits, hehe.

Best wishes, see u in FB andres

Edited: wow, the community and activity I missed the last time here is there! it didn't disappear, it just moved. Well, an example that FB replace forums, seems to me. Different media, but similar effect. I am really glad, absolutely happy, to see the activity continues - 5000 members, constant posts!!! I think I will still publish here, it should work as a repository because FB is too fast, you can't find anything, but also there. Double sometimes, hope it does not bother. Greetings.

leon's picture

Ups, I see Tamas mentioned me this group last year...

leon's picture
Replacing the library of the sensor

You can also replace in the arduino patch the library of the ultrasonic sensor with the detailed math of the sound velocity itself. It is a more stable solution.

/* using a ultrasonic sensor without library */

void setup() {

pinMode(12,OUTPUT); // Trig, sending U-Sound

pinMode(13,INPUT); // Echo

Serial.begin(9600); // to initialize Serial and print distance


void loop() {


delayMicroseconds(10); // USound frequency = 1000 microsecond = 1 millisecond

digitalWrite(12,LOW); // this way I set it to 0

long tt = pulseIn(13,HIGH); // long is a variable of 32 bits, the integrer of only 16

long d = (17*tt)/1000; // converts soundtime to distance in cm


//Serial.print( "cm" );

delay(100); }