Skip to main content

How to connect Arduino with Touchdesigner

How to connect Arduino with Touchdesigner

TouchDesigner is a node based visual programming language for real time interactive multimedia content, developed by the Toronto-based company Derivative.

It is very easy to connect Arduino with TouchDesigner and therefore you can use signals from Arduino to create real-time generative arts easily.

Installing TouchDesginer

TouchDesigner is available for Mac and Windows. Download the latest version of TouchDesigner from here. More details about installation here.

TouchDesginer License Key

There is a free NON-COMMERCIAL license for personal use or learning and not for paying projects. This license includes all basic operations of TouchDesigner and is sufficient for beginners learning purposes. More details about Keying here.

After installation and keying, TouchDesigner should be ready to go!

Setting up Arduino

Arduino Firmata

firmata_menu.png

Firmata is a large piece of Arduino code that, when uploaded to the Arduino, allows users to control the Arduino directly from a computer without writing new code in the Arduino IDE. To find the Firmata code, select Files > Examples > Firmata > StandardFirmata. You should now see the code.

Select the Arduino board and port you, then upload the code and keep the Arduino connected to your computer.

Arduino Circuit

  1. LED to pin 10 with 220Ω resistor
  2. Potentionmeter to pin A0

firmata_circuit.png

Setting up TouchDesigner

TouchDesigner Firmata

TouchDesigner has built-in functionality that allows us to easily interface with the Arduino using Firmata.

  1. Open the Palette inside TD.
  2. Find the firmata under the Tools section.
  3. Click and drag the “firmata” item onto the network editor.

firmata_palette.png

This should create a COMP called “firmata”. This COMP, and its parameters, will be our tool for interfacing with the Arduino. The parameters section has three tabs that we need to work with: firmata, Pin Modes, and Pin Values.

Understanding the Firmata COMP

Parameters of Firmata tab

firmata_firmata.png

  1. Select the port that your Arduino is connected to. This is the same Port that you selected in the Arduino IDE when you uploaded Firmata.
  2. Turn the Active button to on
  3. Turn Report Analog Pins and Report Digital Pins to on

Pin Modes tab

firmata_modes.png

This is where we set the functionality of each pin. We can choose if we want a pin to be Input(1 bit), Output(1 bit), Pullup(1 bit), PWM(8 bit) or Servo(14 bit).

  1. Input(1 bit): This is our “digital read” functionality. we use this to read from physical buttons or switches

  2. Pullup(1 bit): This is a modified version of “digital read” in which the pin is “ON” by default. This is a preferred way of working with physical buttons, as it requires less physical wiring.

  3. Output(1 bit): This is our “digital write” functionality. We use this to turn the pin ON and OFF

  4. PWM(8 bit): This is our “analog write” functionality. We use this to control the brightness of LEDs or the speed of small DC motors.

  5. Servo(14 bit): Ideally you can control Servo Motors from this, but documentation is sparse and untested.

Pin Values tab

firmata_values.png

This is where we can directly control the Arduino Pins. In order to make this work, we need to make sure the pin we want to control has been set to either Output(1 bit) or PWM(8 bit) in the Pin Modes tab. We can then use our CHOP references to control the value of a pin by referencing a channel on a CHOP in our network.

Outputs

outputComp.png

The firmata COMP has two outputs that we will use to extract data from the Arduino. There are several outputs on this COMP, two of them are green and the rest are purple. The green color means that they should connect to a CHOP and the purple color means the output should connect to a DAT. We want to see the data in CHOP form. Connect a Null CHOP to the first (top) green output (renamed as analogIn) and another Null CHOP to the second green output (renamed as digitalIn).

The first green output tells us the values coming in off of the Analog Pins and the second green output tells us the values coming in off of the Digital Pins that have been set to Input(1 bit).

Setting up the panel

How to make/use a reference
Hold and Drag the referencing data, usually a CHOP channel and Drop to the parameters you want to control.
Then select CHOP reference.

More about referencing.

ledNetwork.png

First, setting up a network for controlling the LED (write).

  1. LFO CHOP
  2. Math CHOP - set the range 0 to 1 (map the slider value to 0-1)
  3. Null CHOP - rename this null CHOP to ledPin
  4. In the firmata COMP’s panel, go to the Pin Modes tab and change Pin 10 to PWM(8 bit).
  5. Go to the Pin Values tab and make a reference to the single channel in the ledPin CHOP.

Now, you should see the LED turning on and off.

potNetwork.png

Second, setting up a network for getting signals from the potentiometer (read).

  1. connect a Null CHOP to the top output of the firmata COMP (show us our incoming analog values)
  2. Create a circle TOP
  3. In the circle TOP’s panel, use a reference to the first channel (aka AO pin of Arduino) of the output CHOP to change the radius of the circle.

Now, if you turn the potentionmeter, you should see the size of the circle changing.

You should have something like this at the end. firmata_network.png

If you have trouble setting up the network, you can download the td_firmata.toe file here. Find more details about this tutorial here.