Bonjour à tous,
Je me trouve dans une situation que je ne m'explique pas. Je vous présente mon projet et ensuite mon problème.
Projet : grâce à un ensemble de boutons (6) et à une carte Arduino Mega équipée d'un Shield Ethernet et une librairie OSC (Open Sound Control), j'envoie des données à un premier équipement recevant l'OSC, et j'active aussi des opto-coupleurs sur un second équipement.
En plus de cela, j'ai un Arduino NANO + boutons, équipé d'un module Bluetooth HC-05 qui transmet au MEGA, lui aussi équipé d'un HC-05, des commandes pour actionner les optos.
Les modules Bluetooth sont reliés sur les Pin RX/TX des Arduino, et il y a un pont diviseur sur la pin RX des HC-05.
En résumé :
Arduino Nano -> Bluetooth HC-05 Bluetooth HC-05 ou Bouton -> Arduino MEGA -> OSC
-> Boucle sèche vers opto
Mon problème : Tout fonctionne bien, jusqu'à ce que, pour une raison que j'ignore, les commandes ne répondent plus, la communication Bluetooth s'arrête et plus rien ne fonctionne... Je dois reset la carte pour réussir à nouveau.
J'imagine qu'il y a un problème dans mon code mais impossible de trouver où...
Voici mon code :
//INCLUDE POUR MESSAGE OSC / SHIELD ETHERNET
#include <OSCMessage.h>
/*
Parametrage pour fair un messace OSC message et l'envoyer via UDP
*/
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
EthernetUDP Udp;
//the Arduino's IP
IPAddress ip(192, 168, 1, 18); //Adresse que nous donnons à notre Arduino
//destination IP
IPAddress outIp(192, 168, 1, 1); //Adresse de la Midas
const unsigned int outPort = 10024; //Port de communication de la Midas
byte mac[] = {
0xA8, 0x61, 0x0A, 0xAE, 0x3D, 0x26 }; // Inscrit au dos du shield Ethernet
//---------------------------------------------FIN DE PARAMETRAGE ETHERNET/OSC---------------------------------------------------------
#define pinANIM 22 //BOUTON ANIM
#define pinINVITE 23 //BOUTON INVITE
#define pinHF 24 //BOUTON HF
#define pinRACCRO 25 //BOUTON RACCRO
#define pinREGIE 26 //BOUTON REGIE
#define pinACCUEIL 27 //BOUTON ACCUEIL
// Declaration des variable pour le C11
#define pinRaccroC11 36
#define pinAccueilC11 31
//int pinRougeC11 = 37;
//Declaration de la variable pour lire la liaison série (Bluetooth) avec le Nano
int state = 0;
//Declaration des variables "Bouton"
boolean BoutonANIM;
boolean BoutonREGIE;
boolean BoutonINVITE;
boolean BoutonHF;
boolean BoutonACCUEIL;
boolean BoutonRACCRO;
void setup() {
//initialisation Ethernet
Ethernet.begin(mac,ip);
Udp.begin(8888);
// définition des modes pour les PIN en INPUT pour recevoir les messages des boutons
// /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\/
// /!\ INPUT_PULLUP inverse l'état des entrées (HIGH = LOW et LOW = HIGH)
// /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\
pinMode(pinANIM, INPUT_PULLUP);
pinMode(pinINVITE, INPUT_PULLUP);
pinMode(pinHF, INPUT_PULLUP);
pinMode(pinREGIE, INPUT_PULLUP);
pinMode(pinACCUEIL, INPUT_PULLUP);
pinMode(pinRACCRO, INPUT_PULLUP);
//C11
pinMode(pinRaccroC11, OUTPUT);
pinMode(pinAccueilC11, OUTPUT);
digitalWrite(pinRaccroC11, LOW);
digitalWrite(pinAccueilC11, LOW);
Serial.begin(9600); // Ratio de communication par défaut des modules Bluetooth
}
void loop() {
//lecture de l'état des boutons
BoutonANIM = digitalRead(pinANIM);
BoutonREGIE = digitalRead(pinREGIE);
BoutonINVITE = digitalRead(pinINVITE);
BoutonHF = digitalRead(pinHF);
BoutonACCUEIL = digitalRead(pinACCUEIL);
BoutonRACCRO = digitalRead(pinRACCRO);
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
}
delay(10);
//-------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------PUPITRE TALKBACK OU ANIM-----------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------RACCRO = '1'-----ACCUEIL = '2'-----------------------------------------------------------------
if ((BoutonACCUEIL==LOW) || (state == '2'))//test si bouton appuyé ou si Bouton BT
{
digitalWrite(pinAccueilC11,HIGH);
state = 0;
//Actionne Opto du C11 pour ACCUEIL
}
else if ((BoutonRACCRO==LOW) || (state == '1'))
{
digitalWrite(pinRaccroC11,HIGH);
state = 0;
}
else if (state=='0')
{
digitalWrite(pinRaccroC11,LOW);
digitalWrite(pinAccueilC11,LOW);
state = 0;
}
//---------------------------------------------------------------- ---------------------------------------------------------------
//--------------------------------------------------PUPITRE TALKBACK-------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------
if (BoutonANIM==HIGH)//test si bouton levé
{
OSCMessage msg("/ch/16/mix/01/level");
msg.add((float)0); //(fader à -infini)
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonANIM==LOW)//test si bouton appuyé
{
OSCMessage msg("/ch/16/mix/01/level");
msg.add((float)0.75); //(fader à Zéro
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonREGIE==HIGH)//test si bouton levé
{
OSCMessage msg("/ch/16/mix/fader");
msg.add((float)0);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonREGIE==LOW)//test si bouton appuyé
{
OSCMessage msg("/ch/16/mix/fader");
msg.add((float)0.75);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonINVITE==HIGH)//test si bouton levé
{
OSCMessage msg("/ch/16/mix/02/level");
msg.add((float)0);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonINVITE==LOW)//test si bouton appuyé
{
OSCMessage msg("/ch/16/mix/02/level");
msg.add((float)0.75);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonHF==HIGH)//test si bouton levé
{
OSCMessage msg("/ch/16/mix/03/level");
msg.add((float)0);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
if (BoutonHF==LOW)//test si bouton appuyé
{
OSCMessage msg("/ch/16/mix/03/level");
msg.add((float)0.75);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
delay(10);
}
J'espère avoir été complet dans ce tout premier post.
Je continue à chercher de mon côté et je vous remercie d'avance pour votre aide.
Matériel utilisé :