TouchOSC Fader control led arduino + ethernet shield

I do not know how to make a fader to control the intensity of an LED on the Arduino. I’m using a code where I can light a led via TouchOSC. But I wanted to be able to control the intensity of the LED . I do not know how to read the 0-255 Fader TouchOSC and playing in the port of Arduino PWM.

#include <SPI.h>
#include <Ethernet.h>
#include <ArdOSC.h>  //inclui blibioteca ArdOSC

byte myMac[]={0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};  //define MAC para shield Ethernet
byte myIp[]  = { 192, 168, 1, 177 };   //define IP da central automação
int  serverPort  = 8000;   //define a porta de recepção do comando OSC
int destPort= 9000;   //define a porta de envio do comando OSC
int ledPin =  9;   //define a porta do arduino associada ao led 

int flag=0;

OSCServer server;    //inicializa o servidor OSC (serviço que trata a recepção de mensagem OSC)
OSCClient client;    //inicializa o cliente OSC (serviço que trata o envio de mensagem OSC)

void setup(){ 
 Ethernet.begin(myMac ,myIp);   //inicializa a interface ethernet
 server.begin(serverPort);   //inicializa o servidor OSC definindo a porta de RX
 //set callback function & oscaddress
 server.addCallback("/ard/ledPin",&func1);  //define que a rotina "func1" será executada para o comando OSC "/ard/ledPin"
 pinMode(ledPin, OUTPUT);   //define a porta digital 9 (ledPin) do Arduino como saida
void loop(){
  if(server.aviableCheck()>0){   //verifica se existe alguma mensagem OSC disponível para leitura
 //    Serial.println("alive! "); 

void func1(OSCMessage *_mes){  //rotina que trata comando OSC "/ard/led2" recebido do ANDROID
  int value=(int)_mes->getArgFloat(0);  //armazena em "value" o argumento do comando OSC "/ard/led2"
  digitalWrite(ledPin,value);   //muda estado da porta digital 9 (ledPin2) conforme argumento OSC recebido
  //create new osc message
  OSCMessage txMes;    //cria uma nova menssagem OSC
  //set destination ip address & port no
  txMes.setAddress(_mes->getIpAddress(),destPort);  //define o endereço e porta do destino da mensagem OSC
  txMes.beginMessage("/ard/ledPin");   //define comando OSC
  txMes.addArgFloat(flag);  //define no estado do led 2 que será enviado no argumento OSC para ANDROID
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin, HIGH);
  //send osc message
  client.send(&txMes);   //envia mensagem OSC para atualizar novo estado do led 1 no ANDROID

some help?

  int value=(int)_mes->getArgFloat(0);  //armazena em "value" o argumento do comando OSC "/ard/led2"

Maybe you ought to consider storing the float in a float variable. At least that way you could see what the value is. In another thread, it was mentioned that the fader control returns a value from 0.0 to 1.0. That differs from your assertion that the value is between 0 and 255. Printing the actual value would confirm which of you is right.

still did not work!

waiting for some solution!!!!!!

still did not work!

Something happened. I’m sure that sooner or later you’ll share the results of running the code.