Problems with including different librairies

Hi everyone,

I have a problem that a I don’t really understand.
In my sketch, i’m trying to use two dfferent librairies : Keypad and EasyVr
i have installed this two librairies before but when I try to compile when I unclude this two librairies, it seems that one i ignored and i don’t understand why.

This is my projet : it says that keypad and event keypad were not declared. So I try to put #include after some void but it is the same problem.
I really need you help !

#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 "Keypad.h"
#include "EasyVR.h"
EasyVR easyvr(port);

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {3, 2, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 


const int bit_A = 2;
const int bit_B = 3;
const int bit_C = 4;
const int bit_D = 5;

//Groups and Commands
enum Groups
{
  GROUP_0  = 0,
  GROUP_1  = 1,
};

enum Group0 
{
  G0_ARDUINO = 0,
};

enum Group1 
{
  G1_ETAGE1 = 0,
  G1_ETAGE2 = 1,
  G1_ETAGE3 = 2,
  G1_ETAGE0 = 3,
};


EasyVRBridge bridge;

int8_t group, idx;

void setup(){
#include "Keypad.h"
#include "EasyVr.h"

  Serial.begin(9600);
  keypad.addEventListener(keypadEvent);
{
  // 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(5);

  group = EasyVR::TRIGGER; //<-- start group (customize)
}
{
   //on met les broches en sorties
   pinMode(bit_A, OUTPUT);
   pinMode(bit_B, OUTPUT);
   pinMode(bit_C, OUTPUT);
   pinMode(bit_D, OUTPUT);
 
   //on commence par écrire le chiffre 0, donc toutes les sorites à l'état bas
   digitalWrite(bit_A, LOW);
   digitalWrite(bit_B, LOW);
   digitalWrite(bit_C, LOW);
   digitalWrite(bit_D, LOW);
}
}
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("Veuillez répéter");
    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_ARDUINO:
        // write your action code here
        group = GROUP_1;// group = GROUP_X; <-- or jump to another group X for composite commands
        break;
      }
      break;
    case GROUP_1:
      switch (idx)
      {
      case G1_ETAGE1:
      delay(1000);
        digitalWrite(bit_A, HIGH);
        digitalWrite(bit_B, LOW);
        digitalWrite(bit_C, LOW);
        digitalWrite(bit_D, LOW);
        Serial.println("Etage 1");
        // write your action code here
        group = GROUP_1;// group = GROUP_X; <-- or jump to another group X for composite commands
        break;
      case G1_ETAGE2:
      delay(1000);
        digitalWrite(bit_A, LOW);
        digitalWrite(bit_B, HIGH);
        digitalWrite(bit_C, LOW);
        digitalWrite(bit_D, LOW);
        Serial.println("Etage 2");
        // write your action code here
        group = GROUP_1;// group = GROUP_X; <-- or jump to another group X for composite commands
        break;
      case G1_ETAGE3:
      delay(1000);
        digitalWrite(bit_A, HIGH);
        digitalWrite(bit_B, HIGH);
        digitalWrite(bit_C, LOW);
        digitalWrite(bit_D, LOW);
        Serial.println("Etage 3");// write your action code here
        group = GROUP_1;// group = GROUP_X; <-- or jump to another group X for composite commands
        break;
      case G1_ETAGE0:
      delay(1000);
        digitalWrite(bit_A, LOW);
        digitalWrite(bit_B, LOW);
        digitalWrite(bit_C, LOW);
        digitalWrite(bit_D, LOW);
        Serial.println("Etage 0"); // write your action code here
        group = GROUP_1;// group = GROUP_X; <-- or jump to another group X for composite commands
        break;
      }
      break;
    }
}

This is my projet : it says that keypad and event keypad were not declared. So I try to put #include after some void but it is the same problem. I really need you help !

Then you really need to post a link to the EasyVR library and the EXACT error messages.

Hi,

You need to get organized and do one thing at a time.

Suggestions: http://arduino-info.wikispaces.com/CombiningArduinoSketches

Ok I do it and and have the same problem in void loop :

/* YourDuinoStarter Example: Sketch Template
 - WHAT IT DOES
 - SEE the comments after "//" on each line below
 - CONNECTIONS:
   - 
   - 
 - V1.00 09/11/12
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#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"
#include <Keypad.h>
/*-----( Declare Constants and Pin Numbers )-----*/
const int bit_A = 10;
const int bit_B = 11;
const int bit_C = 12;
const int bit_D = 13;

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
	{'1','2','3'},
	{'4','5','6'},
	{'7','8','9'},
	{'*','0','#'}
	};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad
	
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte ledPin = 13; 

boolean blink = false;

EasyVR easyvr(port);
enum Groups
{
  GROUP_0  = 0,
  GROUP_1  = 1,
};

enum Group0 
{
  G0_ARDUINO = 0,
};

enum Group1 
{
  G1_ETAGE1 = 0,
  G1_ETAGE2 = 1,
  G1_ETAGE3 = 2,
  G1_ETAGE0 = 3,
};


EasyVRBridge bridge;

int8_t group, idx;
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/


void setup()   /****** SETUP: RUNS ONCE ******/
{


}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
Serial.begin(9600);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, HIGH);   // sets the LED on
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
  
  //on met les broches en sorties
   pinMode(bit_A, OUTPUT);
   pinMode(bit_B, OUTPUT);
   pinMode(bit_C, OUTPUT);
   pinMode(bit_D, OUTPUT);
 
   //on commence par écrire le chiffre 0, donc toutes les sorites à l'état bas
   digitalWrite(bit_A, LOW);
   digitalWrite(bit_B, LOW);
   digitalWrite(bit_C, LOW);
   digitalWrite(bit_D, LOW);

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/


//*********( THE END )***********

Error message :
sketch_jun11b.ino: In function ‘void loop()’:
sketch_jun11b:85: error: ‘keypadEvent’ was not declared in this scope

Hi,

Couple of quick things:

PinMode belongs once in SETUP..

Do you have an earlier example of Keypad that you had working?? Maybe start back there and then slowly add things..

Here is my working keypad code (not finished with all number but it is the same) :

#include <Keypad.h>

const int bit_A = 10;
const int bit_B = 11;
const int bit_C = 12;
const int bit_D = 13;

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
	{'1','2','3'},
	{'4','5','6'},
	{'7','8','9'},
	{'*','0','#'}
	};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad
	
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte ledPin = 13; 

boolean blink = false;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, HIGH);   // sets the LED on
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
  pinMode(bit_A, OUTPUT);
   pinMode(bit_B, OUTPUT);
   pinMode(bit_C, OUTPUT);
   pinMode(bit_D, OUTPUT);
}
  
void loop(){
  char key = keypad.getKey();
  
  if (key) {
    Serial.println(key);
  }
  if (blink){
    digitalWrite(ledPin,!digitalRead(ledPin));
    delay(100);
  }
}

//take care of some special events
void keypadEvent(KeypadEvent key){
  switch (keypad.getState()){
    case PRESSED:
      switch (key){
        case '1': 
        digitalWrite(bit_A, HIGH);
        digitalWrite(bit_B, LOW);
        digitalWrite(bit_C, LOW);
        digitalWrite(bit_D, LOW);
        Serial.println("Etage 1");
      
         
        break;
      }
    break;
    case RELEASED:
      switch (key){
        case '*': 
          digitalWrite(ledPin,!digitalRead(ledPin));
          blink = false;
        break;
      }
    break;
    case HOLD:
      switch (key){
        case '*': blink = true; break;
      }
    break;
  }
}

The code in reply #5 has a keypadEvent() method. The code in reply #3 does not. The compiler caught you trying to leave it out.

Yes that's because in reply #3 I stopped to copy my code when I had the problem. In reply #5 there is no error so it's full. I've found something about the different libraries but I'm not english so I don't understand all very well. Perhaps can you help me ? I think that is is my problem :http://provideyourown.com/2011/advanced-arduino-including-multiple-libraries/

I think that is is my problem

Are you writing your own library?

Still haven't seen a link or any exact errors...