[solucionado] easyvr3 encender y apagar

hola chic@s, sigo con este proyecto, haber si me podeis guiar un poco, quiero accionar las luces con un mismo comando,cada vez que dica “luz cocina” me cambie el estado del led.
haber que podeis hacer, un saludo y muchas gracias

#include "Arduino.h"
#if !defined(SERIAL_PORT_MONITOR)
 #error "Arduino version not supported. Please update your IDE to the latest version."
#endif

#if defined(SERIAL_PORT_USBVIRTUAL)
 // Shield Jumper on HW (for Leonardo and Due)
 #define port SERIAL_PORT_HARDWARE
 #define pcSerial SERIAL_PORT_USBVIRTUAL
#else
 // Shield Jumper on SW (using pins 12/13 or 8/9 as RX/TX)
 #include "SoftwareSerial.h"
 SoftwareSerial port(12, 13);
 #define pcSerial SERIAL_PORT_MONITOR
#endif

#include "EasyVR.h"

EasyVR easyvr(port);

//Groups and Commands
enum Groups
{
 GROUP_0  = 0,
 GROUP_1  = 1,
 GROUP_2  = 2,
 GROUP_3  = 3,
 GROUP_4  = 4,
 GROUP_5  = 5,
};

enum Group0 
{
 G0_KIWI = 0,
};

enum Group1 
{
 G1_LUZ_DAVID = 0,
 G1_LUZ_RAKEL = 1,
 G1_MUSICA_DAVID = 2,
 G1_MUSICA_RAKEL = 3,
};

enum Group2 
{
 G2_LUZ_BLANCA_DAVID = 0,
 G2_LUZ_CHILL_OUT_DAVID = 1,
 G2_LUZ_COCINA_DAVID = 2,
 G2_LUZ_COMEDOR_DAVID = 3,
 G2_LUZ_MATRIMONIO_DAVID = 4,
 G2_LUZ_NEREA_DAVID = 5,
 G2_MENU_DAVID = 6,
};

enum Group3 
{
 G3_LUZ_BLANCA_RAKEL = 0,
 G3_LUZ_CHILL_OUT_RAKEL = 1,
 G3_LUZ_COCINA_RAKEL = 2,
 G3_LUZ_COMEDOR_RAKEL = 3,
 G3_LUZ_MATRIMONIO_RAKEL = 4,
 G3_LUZ_NEREA_RAKEL = 5,
 G3_MENU_RAKEL = 6,
};

enum Group4 
{
 G4_PLAY = 0,
 G4_STOP = 1,
 G4_SIGUIENTE = 2,
 G4_MAS_ALTO = 3,
 G4_MAS_BAJO = 4,
 G4_MENU = 5,
};

enum Group5 
{
 G5_PLAY = 0,
 G5_STOP = 1,
 G5_SIGUIENTE = 2,
 G5_MAS_VOLUMEN = 3,
 G5_MENOS_VOLUMEN = 4,
 G5_MENU = 5,
};


int8_t group, idx;

void setup()
{
 // setup PC serial port
 pcSerial.begin(9600);

 // bridge mode?
 int mode = easyvr.bridgeRequested(pcSerial);
 switch (mode)
 {
 case EasyVR::BRIDGE_NONE:
   // setup EasyVR serial port
   port.begin(9600);
   // run normally
   pcSerial.println(F("---"));
   pcSerial.println(F("Bridge not started!"));
   break;
   
 case EasyVR::BRIDGE_NORMAL:
   // setup EasyVR serial port (low speed)
   port.begin(9600);
   // soft-connect the two serial ports (PC and EasyVR)
   easyvr.bridgeLoop(pcSerial);
   // resume normally if aborted
   pcSerial.println(F("---"));
   pcSerial.println(F("Bridge connection aborted!"));
   break;
   
 case EasyVR::BRIDGE_BOOT:
   // setup EasyVR serial port (high speed)
   port.begin(115200);
   // soft-connect the two serial ports (PC and EasyVR)
   easyvr.bridgeLoop(pcSerial);
   // resume normally if aborted
   pcSerial.println(F("---"));
   pcSerial.println(F("Bridge connection aborted!"));
   break;
 }

 while (!easyvr.detect())
 {
   Serial.println("EasyVR not detected!");
   delay(1000);
 }

 easyvr.setPinOutput(EasyVR::IO1, LOW);
 Serial.println("EasyVR detected!");
 easyvr.setTimeout(5);
 easyvr.setLanguage(4);

 group = EasyVR::TRIGGER; //<-- start group (customize)
}

void action();

void loop()
{
 if (easyvr.getID() < EasyVR::EASYVR3)
   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());
 
 if (easyvr.getID() < EasyVR::EASYVR3)
   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();
// beep
   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_KIWI:
       // write your action code here
        group = GROUP_1; //<-- or jump to another group X for composite commands
       break;
     }
     break;
   case GROUP_1:
     switch (idx)
     {
     case G1_LUZ_DAVID:
       // write your action code here
       group = GROUP_1; //<-- or jump to another group X for composite commands
       break;
    
     case G1_MUSICA_DAVID:
       // write your action code here
      group = GROUP_5;// <-- or jump to another group X for composite commands
       break;
     
     }
     break;
   case GROUP_2:
     switch (idx)
     {
     case G2_LUZ_BLANCA_DAVID:
       // write your action code here
       group = GROUP_1; //<-- or jump to another group X for composite commands
       break;
     case G2_LUZ_CHILL_OUT_DAVID:
       // write your action code here
       group = GROUP_1; //<-- or jump to another group X for composite commands
       break;
     case G2_LUZ_COCINA_DAVID:
       // write your action code here
      group = GROUP_1;// <-- or jump to another group X for composite commands
       break;
     }
     break;

habia pensado en hacer algo asi, pero no se si es correcto,

int estado = 0;
void setup() {
 pinMode(3, OUTPUT);

}

void loop() {
case G2_LUZ_COCINA_DAVID: // le pido al easyvr que encienda o apague la luz
estado = digitalRead(3); // le pregunto como esta el led
if(estado == HIGH); // si esta encendido
digitalWrite(3,LOW); // apaga el led
else (
 digitalWrite(3,HIGH); // si no esta encendido , enciende
easyvr.playSound(0, EasyVR::VOL_FULL);// contesta con luz cocina
 )
break;

conseguido!!en resumido...

int blanca = 2;


void setup()

 
 pinMode(2,OUTPUT);


void action()
case GROUP_2:
     switch (idx)
     {
       case G2_LUZ_BLANCA_DAVID:
         digitalWrite(blanca, !digitalRead(blanca));
         easyvr.playSound(8, EasyVR::VOL_FULL);
         group = GROUP_2;
         break;

Bueno al final, lo has logrado tu mismo, felicitaciones!!

NOTA: Te doy la gracias por haber corregido los post y que se vean con etiquetas.

chic@s!!! os he dejado un tutorial completito en el apartado documentacion se llama "Easyvr3 Tutorial principiante". completamente desde 0, que programas y librerias necesitas, donde conseguirlos. y un paso a paso con fotografias para poner en marcha tu easyvr3.

espero que os guste!!