Hello!
I am trying to connect Arduino with a i thought a simple button, to send a command to MAX MSP, wich at the same time communicates to a light console ETC nomad. All is working from the same computer.
I get MAX to work wit the etc but i cannot get Arduino to communicate with max. In the end the button should activate the command from max and this one has the command for the light console.
//constantes
const int botonPin = 5; // Asignar botón al pin 5 del Arduino
const int ledAzul = 3; // Asignar LED al pin 3 del Arduino
int estadoBoton = 0; //variable para leer estado pulsador
void setup() {
Serial.begin(9600); // Inicializar el puerto serie para depuración
pinMode(botonPin, INPUT); // Configurar pin del botón como entrada
pinMode(ledAzul, OUTPUT); // Configurar pin del LED como salida
}
void loop() {
estadoBoton = digitalRead(botonPin); // Leer el estado del botón
if (estadoBoton == HIGH) { // Si el botón está presionado
// Enviar un mensaje por el puerto serie
Serial.println("Buttonpressed");
digitalWrite(ledAzul, HIGH); // Encender el LED
delay(10000);
// Esperar un tiempo antes de verificar el botón de nuevo
//delay(1000); // Espera 1 segundo (ajusta según sea necesario)
} else {
digitalWrite(ledAzul, LOW); // Apagar el LED cuando el botón no esté presionado
}
//Leer la confirmacion de MAX
if(Serial.available() > 0){
String confirmacion = Serial.readStringUntil('\n');
if(confirmacion == "Mensaje recibido"){
Serial.println("Confirmacion recibida desde MAX");
}
}
delay(50);
}