Python - SimpleOSC : v0.2.5 - Great little Python API for talking to OSC
Here's some minimal code examples that I came up with last night to talk to the Make Controller. These are as minimal as you can get, just the most basic functions so you can see what is going on clearly.
testDigitalOut
#!/usr/bin/python
import osc
def testDigitalOut():
""" a minimal function that flashes an LED connected to the
first digital output on the Make Controller
"""
osc.init()
import time
i = 1
while 1:
i = (i + 1) % 2
print i
osc.sendMsg("/digitalout/0/value", [i], "192.168.1.101", 10000)
time.sleep(0.5)
osc.dontListen()
if __name__ == '__main__': testDigitalOut()
testAnalogIn
#!/usr/bin/python
import osc
def testAnalogIn():
""" a simple function that requests the value of the first
analog input on the Make Controller
"""
osc.init()
osc.listen('192.168.1.65', 10000)
osc.bind(printStuff, "/analogin/0/value")
import time
while 1:
osc.sendMsg("/analogin/0/value", [], "192.168.1.101", 10000)
time.sleep(0.5)
osc.dontListen()
def printStuff(*msg):
"""deals with "print" tagged OSC addresses """
print msg[0][0], "=", msg[0][2]
if __name__ == '__main__': testAnalogIn()