Hello there!
At the university I was trying to develop a little version of the lighthack box 1. My idea was to have at first just one button, which can have any use i could need. I have been trying to get arduino to connect to the nomad but I can't really figure out what am I doing wrong.
I have OSC RX enabled on the etc and also Log UDP on, whic I don´t really know what this does. The IP Adress and the port is also correct i think.
I cannot make the connection between a simple pulsator on my protoboard, to fire a "go to cue 1" through an "if" conditional.
If someone could help me that would be amazing!
Thanks so much,
KY
#include <Ethernet.h> // Incluimos la librería Ethernet
#include <EthernetUdp.h> // Incluimos la librería UDP
#include <OSCMessage.h> // Incluimos la librería OSC
//#include <Keypad.h> //incluir libreria para manejar el teclado del ordenador
//asignar botón al pin 5 del arduino
const int botonpin = 2;
//el estado del boton lo añado luego
// Definimos la dirección IP y el puerto de la consola Nomad
IPAddress nomadIP(192, 168, 0, 17); // Dirección de loopback en el mismo Mac
const unsigned int nomadPort = 8000; // Puerto OSC predeterminado de la consola Nomad
// Definimos el objeto UDP
EthernetUDP Udp;
void setup() {
  //configurar pin como salida
  pinMode(botonpin, INPUT);
  // Inicializamos el puerto serie para mensajes de depuración
  Serial.begin(9600);
  // Inicializamos la conexión Ethernet y el objeto UDP
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
  Ethernet.begin(mac,nomadPort); // Reemplaza 'mac' con la dirección MAC de tu placa Arduino
  //Udp.begin(nomadPort);??
  //ver cual es el puerto y el ip
  Serial.println("Nomad IP: " + String(nomadIP));
  Serial.println("Nomad Port: " + String(nomadPort));
  //pinMode(botonpin, INPUT);
  
}
void loop() {
  // 1) el boton 1 es el que escribe go to cue 1.
  
  //INICIAR LECTURA ESTADO BOTON para detectar el estado del boton
  //Leer estado boton
  int estadoBoton = digitalRead(botonpin);
  //inicio if
  if(estadoBoton == HIGH){
    // Creamos un mensaje OSC. seleccionar un canal concreto
    OSCMessage selectChannel("/eos/outgoing/goToCue/1");
    //selectChannel.add("1"); // Puedes agregar diferentes tipos de datos (int, float, etc.) al mensaje según sea necesario
    
    //Hay qeu agregar el contenido del mensaje osc al paquete utilizado
    selectChannel.send(Udp);
    // Enviamos el paquete con mensaje OSC a la consola Nomad
    //Udp.beginPacket(nomadIP, nomadPort);
    Udp.endPacket();
    // Borramos el contenido del mensaje para reutilizarlo en la siguiente iteración del bucle
    selectChannel.empty();
    Serial.println("Nomad IP: " + String(nomadIP));
  }
  // Esperamos un tiempo antes de enviar el siguiente mensaje (opcional)
  delay(1000); // Espera 1 segundo antes de enviar el siguiente mensaje, ajusta según sea necesario
  /*
  // 2) El botón 2 esta para poner el canal 34+35+36
  //Mensaje OSC para decirle a la nomad de poner el canal anterior a full
  OSCMessage setIntensity("/eos/user/1/Intensity/Full");
  Udp.beginPacket(nomadIP, nomadPort);
  //setIntensity.beginPacket(nomadIP,nomadPort);
  setIntensity.send(Udp);
  Udp.endPacket();
  setIntensity.empty(); //este funciona como un clear
  */
//correccion chat gpt
/*Udp.beginPacket(nomadIP, nomadPort);
setIntensity.send(Udp);
Udp.endPacket();*/
  
}
