Products Applications Downloads Features Wiki forum Store

Arduino

From Wiki077
Jump to: navigation, search

TouchDesigner supports Arduino via the Serial DAT.

Example Videos: Here is a video by Rob Bairos showing TouchDesigner and Arduino: [1]. Another by Markus Heckmann presenting at MUTEK: [2]. Dave Robert at MIT on Never-Ending Drawing Machine (cue to 3:15 and to 7:50): [3].

Using Arduino

Begin by installing Arduino, and any necessary serial drivers.

Here is an example file: Media:Arduino sample.tox

The following simple sketch will output some values once per second:

void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
}
void loop()
{
  delay(1000);
   
  int  i = 1234;
  Serial.print(i, DEC);
  Serial.print('\n');
 
  float f = 321.7;
  Serial.print(f);
  Serial.print('\n');
}

In order to receive these messages in TouchDesigner, place down a Serial DAT. By default, all the parameters should be compatible with the above sketch and you should see these two values arriving in the DAT every second.

More specifically, make sure the communication parameters are set to the same baud rate as the Arduino. By default the settings are 9600,8,N,2 but the baud rate can be increased if required. Also, make sure the Table Format is set to One Row Per Line.

The above sketch outputs a single new line character '\n' after each value. Unfortunately, executing a println() command will not work in this case, as it outputs both a carriage return and a new line, which are interpreted as blank lines in the Serial In DAT.

To see the actual received byte values at any time, turn on the Value Column parameter under the Received Messages parameter

Make sure to turn off the Active parameter in the Serial DAT, while using the Arduino to upload new sketches over the shared serial connection.

Turn the Active parameter back on after the sketch is uploaded.

Alternatively, for binary communication, the sketch print statements could output individual bytes:

char a = 123;
Serial.print(a, BYTE);

In this case, the Serial In DAT Table Format should be set to One Row Per Byte.

Make sure to turn on 'Value Column' in the DAT to show their numeric values.


Finally, to output characters back to the Arduino, use the send Command. Bytes can be sent through the same Serial DAT. Use the Arduino commands: Serial.available() and Serial.read() to access these bytes on the Arduino.

Personal tools