Right I hope someone can help as I am a bit stumped.
I have been following the tutorial from here Freelance Winnipeg PHP Developer | Nick Verwymeren and can't seem to get it quit working.
The code is
// OSCClass iOSC(iPhone App) test sketch
// OSCClass version 1.0.1 (Arduino ver0014)
// Copyright (c) recotana(http://recotana.com). All right reserved.
// Modified by Nick Verwymeren (http://makesomecode.com) December 30, 2009/*
iOSC is OSCsend Application for iPhone
iOSCiOSC setting
OSCMessage type value on off
slider1 /dmx/ledblu float 1 0
slider2 /dmx/ledgrn float 1 0
slider3 /dmx/ledred float 1 0host setting IP address 192.168.100.206 , port 10000
*/
#include "Ethernet.h"
#include "OSCClass.h"
#include <DmxSimple.h>OSCMessage recMes;
OSCClass osc(&recMes);
byte serverMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte serverIp[] = { 192, 168, 100, 206 };
int serverPort = 10000;// byte gateway[] = { 192, 168, 0, 1 };
// byte subnet[] = { 255, 255, 255, 0 };char *topAddress="dmx";
//Currently ledpwm is not implemented
char *subAddress[4]={ "ledred" , "ledgrn" , "ledblu" , "ledpwm"};void setup() {
//Serial.begin(19200); //Uncomment for serial debugging
//If your LED light is set to DMX channel 1 it will use the 1 for red, 2 for green, 3 for blue, and 4 for brightness.
//Use digital pin 3 for DMX output
DmxSimple.usePin(3);
DmxSimple.maxChannel(4);//Set DMX channel 4 to full brightness
DmxSimple.write(4, 255);
Ethernet.begin(serverMac ,serverIp);//setting osc recieve server
osc.begin(serverPort);//osc message buffer clear
osc.flush();}
void loop() {
//Do we have an OSC message?
if ( osc.available() ) {//Uncomment below line for debugging through serial port
//logMessage(&recMes);//toplevel address matching
if( !strcmp( recMes.getAddress(0) , topAddress ) ){//Get our variables from the message
char *channel = recMes.getAddress(1);
float value = (float)recMes.getArgFloat(0);//Convert our float value to integer
int intvalue = int(255.0*value);//Send out the DMX values
DmxSimple.write(atoi(channel), intvalue);
}}
}
// ********* utility ***********************************
void logMessage(OSCMessage *mes){
uint8_t *ip=mes->getIp();
//disp ip & port
Serial.print("from IP:");
Serial.print(ip[0],DEC);
Serial.print(".");
Serial.print(ip[1],DEC);
Serial.print(".");
Serial.print(ip[2],DEC);
Serial.print(".");
Serial.print(ip[3],DEC);
Serial.print(" port:");
Serial.print(mes->getPort(),DEC);
Serial.print(" ");//disp adr
for(int i = 0 ; i < mes->getAddressNum() ; i++){Serial.print(mes->getAddress(i));
}
//disp type tags
Serial.print(" ,");
for(int i = 0 ; i < mes->getArgNum() ; i++){Serial.print(mes->getTypeTag(i));
}
Serial.print(" ");//disp args
for(int i = 0 ; i < mes->getArgNum() ; i++){switch( mes->getTypeTag(i) ){
case 'i': {
Serial.print( mes->getArgInt(i) );
}
break;case 'f': {
Serial.print( mes->getArgFloat(i) );
}
break;}
Serial.print(" ");
}
Serial.println("");
}
I have everything in place, I can send DMX I can read in the OSC message but there seems to be a problem converting the second adress string to a value. I can debug it and get the correct string but
DmxSimple.write(atoi(channel), intvalue);
seems to only return a zero for the dmx channel which is no go as I want a number between 1-3.
Anyway if anyone can point me in the right direction that would be great.
Cheers
Steve