How do I use a contact closure as trigger over a serial connection?

Hey, so I’m going to be dabbling in some really basic serial communication in a bit. The idea is to use a contact closure (A hacked Staples Easy Button) to trigger an event in my composition. I have a couple copycat Arduino Pro Micros and a couple of Pro Minis on order and plan to put one inside the Staples Easy Button which would be connected to my Mac via a USB cable. The Micro has an ATmega32U4 chip which supports native USB-HID and the Pro Mini has an ATmega328P which supports USB-Serial so I thought that will cover either type of communication I might want. It also crossed my mind that I might want to make an LED inside the Easy Button flash during a part of the composition as well so that would require communication both ways.

I’m really looking forward to playing around with VUO this way and have been reading about the HID and Serial nodes a bit. Even so I haven’t found a lot of examples of them in use yet. What would be the simplest way for me to do this project? Are there any good Vuo/Arduino resources for me to read?

1 Like

Here’s an overview of using a switch with Arduino over USB Serial:

1: Wire up a circuit so that digital pin 2 gets +5V when the switch is pressed, and gets 0V when it isn’t pressed — see for details.

2: Write a program for the Arduino that outputs the switch status over USB serial. For example:

const int switchPin = 2;
int switchStatus = 0;

void setup() {
    Serial.begin(9600, SERIAL_8N1);
    pinMode(switchPin, INPUT);

void loop() {
    int currentSwitchStatus = digitalRead(switchPin);
    if (currentSwitchStatus != switchStatus) {
        switchStatus = currentSwitchStatus;

3: Compile and upload the program to the Arduino.

  • Use the Arduino app’s Serial Monitor to confirm that the Arduino is sending “1” when the switch is pressed and “0” when it is released.

4: In Vuo, open the “Log Text from Serial Device” example, select the Arduino in the Receive Serial Data node’s Device port, and Run.

  • Confirm that Vuo is receiving the Arduino’s data.
  • Connect Split Text Stream -> Convert Text to Integer -> Is Integer Nonzero to use the switch’s status to affect other parts of your Vuo composition.

Thank-you Jaymie! This is exactly what I was looking for.

1 Like

So I did get this working but I think I need to implement something called “debounce” because sometimes the logger reports 2 or 3 repeats of the command with a single press (once it showed 11!!!). Anyway it technically isn’t affecting the functioning of my composition because you can’t trigger an event more than once every 4 seconds but I would like to make this function properly. I kind of understand the debounce example here but it doesn’t seem to be working when I implement it. How would you implement debounce on the program above?

Here’s a solution that debounces within the Vuo composition rather than the Arduino code.

debounce.vuo (4.44 KB)

1 Like

Awesome. Thank-you.