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?

Comments

Here's an overview of using a

jstrecker's picture
Submitted by

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 https://www.arduino.cc/en/tutorial/button 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) {
        Serial.println(currentSwitchStatus);
        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.