Bonjour ou bonsoir a tous !
Je suis actuellement en train de programmer une chaîne hi-fi a reconnaissance vocale, à l’aide d’une carte Arduino Uno R3, d’un module EasyVR et d’un autre module MP3 player shield de chez Sparkfun.
En réalité le montage ne servira pas seulement de chaîne hi-fi, puisqu’il y aura aussi des fonctions domotiques (gestion de volets, de lumières).
Mais actuellement, lorsque j’initialise mon shield MP3, le module EasyVR ne fonctionne plus. Il ne se coupe pas, mais il ne réponds plus (plante-t-il ? Est-ce un autre problème ? J’arrive pas a savoir ^^’).
Les deux shields sont-ils incompatibles ?
Ci-joint, mon code. Je n’ai pas inclus l’initialisation du MP3 player shield parce que je ne sais pas exactement ou le mettre (étant débutant, j’avance par tâtonnement )
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
NewSoftSerial port(12,13);
#endif
#include "EasyVR.h"
EasyVR easyvr(port);
//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
GROUP_2 = 2,
};
enum Group0
{
G0_ALFRED = 0,
};
enum Group1
{
G1_ALLUME = 0,
G1_ETEINT = 1,
G1_OUVRIR = 2,
G1_FERMER = 3,
G1_LANCE_CHANSON = 4,
G1_CHANSON_SUIVANTE = 5,
G1_CHANSON_PRECEDENTE = 6,
};
enum Group2
{
G2_SALON = 0,
G2_CUISINE = 1,
G2_PARTOUT = 2,
G2_CHAMBRE1 = 3,
G2_CHAMBRE2 = 4,
};
EasyVRBridge bridge;
int8_t group, idx, result;
int nbr=2;
SdFat sd;
SFEMP3Shield MP3player;
void setup()
{
// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally
Serial.begin(9600);
port.begin(9600);
if (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
for (;;);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(0);
group = EasyVR::TRIGGER; //<-- start group (customize)
}
void action()
;
void loop()
{
easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
Serial.print("Say a command in Group ");
Serial.println(group);
easyvr.recognizeCommand(group);
do
{
// can do some processing while waiting for a spoken command
}
while (!easyvr.hasFinished());
easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
idx = easyvr.getWord();
if (idx >= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; <-- jump to another group X
return;
}
idx = easyvr.getCommand();
if (idx >= 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print("Command: ");
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}
}
void action()
{
switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_ALFRED:
group = GROUP_1;
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_ALLUME:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_ETEINT:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_OUVRIR:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_FERMER:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_LANCE_CHANSON:
MP3player.playTrack(nbr);
group = GROUP_0;
break;
case G1_CHANSON_SUIVANTE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_CHANSON_PRECEDENTE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_2:
switch (idx)
{
case G2_SALON:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G2_CUISINE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G2_PARTOUT:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G2_CHAMBRE1:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G2_CHAMBRE2:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
}
}
En espérant que quelqu’un saura trouver une solution.
Bonne journée/Soirée a tous :).