I am looking to use OSC between my Arduino and Desktop.
I am looking to use this library: deadpixel » Arduino OSC
I am having trouble getting off of the ground. How to I specify which port I am going to use?
I only see this with the Ethernet version. Am I missing something?
Here is the code:
// MESSAGE PROTOCOL OBJECT
#include <OscSerial.h>
// tile support libraries
#include <EthernetUdp.h>
#include <SPI.h>
OscSerial oscSerial;
long timer;
void setup() {
Serial.begin(9600);
oscSerial.begin(Serial);
pinMode(13, OUTPUT);
}
void loop() {
// send a message every 100 ms
// avoid using delay() since it just blocks everything
long now = millis();
if (now-timer > 100) {
OscMessage msg("/helloFromArduino");
msg.add(0); // <-- this could be any data
oscSerial.send(msg);
timer = now;
}
// important!
oscSerial.listen();
}
void oscEvent(OscMessage &m) { // *note the & before msg
// receive a message
m.plug("/led", myFunction);
}
void myFunction(OscMessage &m) { // *note the & before msg
// getting to the message data
int value = m.getInt(0);
if (value == 0) digitalWrite(13, LOW);
if (value == 1) digitalWrite(13, HIGH);
}