Write to Arduino No firmata
1. Send data from Touchdesigner
Firmata
Palette —> tools —> Firmata
CHOP Execute DAT =
2. Arduino received data
Firmata
file --> example --> Firmata --> StanderFirmata
Serial.read()
Arduino code
1#define led01 12
2#define led02 13
3//constant from Touchdesigner
4byte degreesTouchdesigner; //setpoint send by Touchdesigner
5
6void setup() {
7 //start serial port at 9600 bps:
8 Serial.begin(9600);
9 while (!Serial)
10 {
11 ;// wait for serial port to connect. Needed for native USB port only.
12 }
13 // Declare pins as output:
14 pinMode(led01, OUTPUT);
15 pinMode(led02, OUTPUT);
16}
17
18void loop() {
19 if(Serial.available() > 0)
20 {
21 degreesTouchdesigner = Serial.read(); // read the values from Touchdesigner
22 Serial.print(degreesTouchdesigner);
23 if (degreesTouchdesigner>120)
24 {
25 digitalWrite(led01,LOW);
26 digitalWrite(led02,HIGH);
27 }
28 else
29 {
30 digitalWrite(led02,LOW);
31 digitalWrite(led01,HIGH);
32 }
33 }
34}
in TouchDesigner:
serial1 op
one per byte
CHOP Execute: select the CHOPS. Channels.
code:
# me - this DAT
#
# channel - the Channel object which has changed
# sampleIndex - the index of the changed sample
# val - the numeric value of the changed sample
# prev - the previous sample value
#
# Make sure the corresponding toggle is enabled in the CHOP Execute DAT.
def onOffToOn(channel, sampleIndex, val, prev):
return
def whileOn(channel, sampleIndex, val, prev):
return
def onOnToOff(channel, sampleIndex, val, prev):
return
def whileOff(channel, sampleIndex, val, prev):
return
def onValueChange(channel, sampleIndex, val, prev):
op('serial1').sendBytes(val)
return