Hi,
i am currently on a project to control DMX parcan with ipad,
my current progress, i am able to control it with ethernet shield mounted on arduino, and connected to a router.
my next step would be replacing the ethernet shield with the wifly 2.21 RN-131G.
is there like any examples or tutorials out there to use as reference?
would prefer not to use http, kinda a hassle.
please do guide me along as im still kinda new to arduino dev and programming.
am using arduino uno R3, Ethernet Shield R3, wifly 2.21 RN-131G, TouchOSC or iOSC
and here's my code for the ethernet part:
#include "Ethernet.h"
#include "OSCClass.h"
#include <DmxSimple.h>
#include "SPI.h"
OSCMessage recMes;
OSCClass osc(&recMes);
byte serverMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte serverIp[] = { 192, 168, 0, 101 };
int serverPort = 10000;
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
char *topAddress="dmx";
int alphaCh = 19; //This should be the 4th value of the DMX light you're trying to control. For example if your light is set to DMX channel 44 the alpha channel would be 47.
void setup() {
Serial.begin(9600); //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(5);
//Set DMX alpha channel to full brightness. We do not currently support brightness so we set it to full.
//DmxSimple.write(alphaCh, 0);
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
// Serial.print("Sending to DMX: ");
// Serial.print(atoi(channel),DEC);
// Serial.print(' ');
// Serial.println(intvalue, DEC);
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("");
}