Hi there - im pretty new to Arduino and programming but slowly getting to grips. Come across a issue and after lots of research i just cannot work away round it. I am trying to send OSC messages with a variable in the address. The variable is a random number which is generated. The messsage I am trying to send is "/Test/x" where x is the random number. Using some examples from the OSC library from CNMAT i have the following -
#include <OSCMessage.h>
#include <OSCMessage.h>
/*
Make an OSC message and send it over UDP
Adrian Freed
*/
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCMessage.h>
EthernetUDP Udp;
//the Arduino's IP
IPAddress ip(192, 168, 0, 2);
//destination IP
IPAddress outIp(192, 168, 0, 1);
const unsigned int outPort = 9999;
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0D, 0xC0, 0x85 }; // you can find this written on the board of some Arduino Ethernets or shields
void setup() {
Ethernet.begin(mac,ip);
Udp.begin(8888);
Serial.begin(9600);
}
void loop(){
//the message wants an OSC address as first argument
int Address(random(1 ,51));
int i = Address;
OSCMessage msg =("/Test/"+i);
msg.add(1);
Serial.println(value);
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(50);
}
I have tried several ways of concatenating the number into this string but to no avail - anyone offer any assistance out there?
Thanks