This week we worked with outputs created by an arduino that create effects in touchdesigner and outputs from touchdesigner generators that cause effects on the arduino.
This program reads a voltage from a potentiometer and sends it as a value from 1-255 using the Serial.write function (which sends the number as one byte of data as opposed to serial.print, which sends each numeral as an individual byte).
Conversely, we can also generate data inside touchdesigner that has an effect on a physical arduino device. For example, this slider can be combined with a math (for conversion) and a null node to send data to a PWM pin to control the brightness of an LED.
For this example, the pre-set LED brightness example in the Arduino IDE will work.
Instead of receiving serial data from the arduino, this python script allows serial data to be sent to the arduino, which controls the brightness:
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
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.