Hi all. This is my first post - pleased to meet you.
I'm doing my third project using OSC from an Arduino. My first involved reading several hundred switches, and OSC was used like an array, and the second was a number of piezos being read on the analog inputs.
These were about a year and a half/2 years ago, and right now I just need to read a single pot value from analog 1.
I can't seem to get the code working at all - it's strange as it is the same code I had used previously, with minor modifications.
Here are two versions of my code - one using bundle, one not.
I have my computer's IP address set to 128.32.122.125
I'm debugging with OSCulator and Max/MSP, which are accepting OSC normally. If anyone has any ideas I'd be very grateful. Is it possible this is a new revision of the Ethernet shield that doesn't work in the same way?
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
EthernetUDP Udp;
//the Arduino's IP
IPAddress ip(128, 32, 122, 252);
//destination IP
IPAddress outIp(128, 32, 122, 125);
const unsigned int outPort = 9999;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields
void setup() {
Ethernet.begin(mac,ip);
Udp.begin(8888);
}
void loop(){
//the message wants an OSC address as first argument
OSCMessage msg("/analog/0");
msg.add(analogRead(0));
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
delay(20);
}
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
EthernetUDP Udp;
//the Arduino's IP
IPAddress ip(128, 32, 122, 252);
//destination IP
IPAddress outIp(128, 32, 122, 125);
const unsigned int outPort = 9999;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields
void setup() {
Ethernet.begin(mac,ip);
Udp.begin(8888);
}
void loop(){
//declare the bundle
OSCBundle bndl;
//BOSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together
bndl.add("/analog/0").add((int32_t)analogRead(0));
Udp.beginPacket(outIp, outPort);
bndl.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
bndl.empty(); // empty the bundle to free room for a new one
delay(5);
}