Cambio en codigo de liquidcrystal a i2c (resuelto)

Muy buenas compañeros me planteo una duda y a ver si se pudiera hacer algo ,tengo este código y e trabajado con el y todo muy bien,ahora la pregunta es la siguiente¿puedo cambiar en el código la librería por la i2c? se que el código esta preparado para la liquidcrystal normal pero con i2c me ahorro mucho cableado pues es para colocarlo en un sitio muy pequeño y esto me ahorra mucho espacio y dolores de cabeza.

si es asi me ¿podeis ayudar en conseguirlo?

Gracias de antemano.

#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Tone.h>
#define pound 14

Tone tone1;

int Scount = 60; // count seconds
int Mcount = 1; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0

long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds

char password[4] = {'0', '4', '8', '9'}; // PASSWORD E 1234 DEFINIDA AQUI!!!!
int currentLength = 0; //defines which number we are currently writing
int i = 0; 
char entered[4];

int ledPin = 4; //red led
int ledPin2 = 3; //yellow led
int ledPin3 = 2; //green led

LiquidCrystal lcd(7,8,10,11,12,13); // the pins we use on the LCD

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] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup(){
  pinMode(ledPin, OUTPUT); // sets the digital pin as output
  pinMode(ledPin2, OUTPUT); // sets the digital pin as output
  pinMode(ledPin3, OUTPUT); // sets the digital pin as output
  tone1.begin(9);
  lcd.begin(16, 2);
  Serial.begin(9600);
  lcd.clear();
  lcd.setCursor(0,0);


  lcd.print(" CODIGO ");
  while (currentLength < 4)
  {
    lcd.setCursor(currentLength + 6, 1);
    lcd.cursor();
    char key = keypad.getKey();
    key == NO_KEY;
    if (key != NO_KEY)
    {
      if ((key != '*')&&(key != '#'))
      { 
      lcd.print(key);
      password[currentLength] = key;
      currentLength++;
      tone1.play(NOTE_C6, 200);
      }
    }
  }

  if (currentLength == 4)
  {
    delay(500);
    lcd.noCursor();
    lcd.clear();
    lcd.home();
    lcd.print(" CONFIRMA CODIGO");
    lcd.setCursor(6,1);
    lcd.print(password[0]);
    lcd.print(password[1]);
    lcd.print(password[2]);
    lcd.print(password[3]);

    tone1.play(NOTE_E6, 200);
    delay(3000);
    lcd.clear();
    currentLength = 0;
  }
}

void loop()
{
  timer();
  char key2 = keypad.getKey(); // get the key
  
  if (key2 == '*')
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("CODIGO: ");
      
      while (currentLength < 4)
        {
          
          timer();
          
          char key2 = keypad.getKey(); 
          if (key2 == '#')
            {
              currentLength = 0;
              lcd.clear();
              lcd.setCursor(0,0);
              lcd.print("Code: ");
            }
          else                  
          if (key2 != NO_KEY)    
            {
              
              lcd.setCursor(currentLength + 7, 0);
              lcd.cursor();
              
              lcd.print(key2);
              entered[currentLength] = key2;
              currentLength++;
              tone1.play(NOTE_C6, 200);
              delay(100);
              lcd.noCursor();
              lcd.setCursor(currentLength + 6, 0);
              lcd.print("*");
              lcd.setCursor(currentLength + 7, 0);
              lcd.cursor();
            }
        }

      if (currentLength == 4) 
        {
          if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
            {
              lcd.noCursor();
              lcd.clear();
              lcd.home();
              lcd.print ("  ");
              currentLength = 0;
              digitalWrite(ledPin3, HIGH);
              delay(2500);
              lcd.setCursor(0,1);
              lcd.print("  ");
              delay(1000000);
            }
      else
        {
          lcd.noCursor();
          lcd.clear();
          lcd.home();
          lcd.print("  ");
    
          if (Hcount > 0)
            {
              Hcount = Hcount - 1;
            }
    
          if (Mcount > 0)
            {
              Mcount = Mcount - 59;
            }
          if (Scount > 0)
            {
              Scount = Scount - 59;
            }
        delay(1500);
        currentLength = 0;
  
        }
      }  
    }
}

void timer()
{
  Serial.print(Scount);
  Serial.println();
  
  if (Hcount <= 0)
  {
    if ( Mcount < 0 )
    {
      lcd.noCursor();
      lcd.clear();
      lcd.home();
      lcd.print("    ");
      lcd.setCursor (0,1);
      lcd.print("    ");
      
      while (Mcount < 0) 
      {
        digitalWrite(ledPin, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100); 
        digitalWrite(ledPin, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100); 
        digitalWrite(ledPin2, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100); 
        digitalWrite(ledPin2, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100); 
        digitalWrite(ledPin3, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100); 
        digitalWrite(ledPin3, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
      }
    } 
  }

  lcd.setCursor (0,1); // sets cursor to 2nd line
  lcd.print ("QUEDAN:");

  if (Hcount >= 10)
    {
      lcd.setCursor (7,1);
      lcd.print (Hcount);
    }
  if (Hcount < 10) 
    {
      lcd.setCursor (7,1);
      lcd.write ("0");
      lcd.setCursor (8,1);
      lcd.print (Hcount);
    }

  lcd.print (":");

  if (Mcount >= 10)
    {
      lcd.setCursor (10,1);
      lcd.print (Mcount);
    }
  if (Mcount < 10) 
    {
      lcd.setCursor (10,1);
      lcd.write ("0");
      lcd.setCursor (11,1);
      lcd.print (Mcount);
    }
    
  lcd.print (":");

  if (Scount >= 10) 
    {
      lcd.setCursor (13,1);
      lcd.print (Scount);
    }
  if (Scount < 10) 
    {
      lcd.setCursor (13,1);
      lcd.write ("0");
      lcd.setCursor (14,1);
      lcd.print (Scount);
    }

  if (Hcount <0) 
    {
      Hcount = 0; 
    }

  if (Mcount <0) 
    {
      Hcount --; 
      Mcount = 59; 
    }

  if (Scount <1) // if 60 do this operation
    {
      Mcount --; // add 1 to Mcount
      Scount = 59; // reset Scount
    }

  if (Scount > 0) // do this oper. 59 times
    {
      unsigned long currentMillis = millis();
  
      if(currentMillis - secMillis > interval) 
        {
          tone1.play(NOTE_G5, 200);
          secMillis = currentMillis;
          Scount --; // add 1 to Scount
          digitalWrite(ledPin2, HIGH); // sets the LED on
          delay(10); // waits for a second
          digitalWrite(ledPin2, LOW); // sets the LED off
          delay(10); // waits for a second
          //lcd.clear();
        }
    }
}

Mi consejo es que uses la libreria de fmalpartida.

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip

Instálala como Liquidcrystal_i2c para que no entre en conflicto con la otra.

La inicialización que a mi me funciona con esa librería es esta:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
  lcd.begin(16, 2);
}

Gracias por atención carmeloco,e echo lo que me dices y me este error.

Arduino:1.6.3 (Windows 7), Placa:"Arduino Uno"

CCS.ino: In function 'void setup()':

CCS.ino:46:6: error: redefinition of 'void setup()'

CCS.ino:28:6: error: 'void setup()' previously defined here

Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias

Por el error, veo que has definido un segundo void setup.

En el código que yo te puse, hay un void setup, pero para que pongas lo que hay dentro de ese void setup, en el tuyo, no para que definas uno nuevo. lo que hay al principio, tambien va al principio de todo del código.

Si no pones el código nuevo aqui, es todo lo que te puedo decir.

Disculpa mi ignorancia carmeloco,si lo e definido al principio,llevo poco con programación de arduino y sigo tutoriales y enlaces pero aun no estoy muy enterado de como funcionan exactamente los códigos,el código de arriba es el original,hice una copia para ir probando pero al final de hacer varias cosas e decidido borrarlo por que cada vez me daba mas errores,si eres tan amable de decirme exactamente donde colocarlo o que líneas tengo que cambiar unas por otras te estaría muy agradecido.

Vaaale, te lo pongo en tu código, jajajaja

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#include <Tone.h>
#define pound 14

Tone tone1;

int Scount = 60; // count seconds
int Mcount = 1; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0

long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds

char password[4] = {'0', '4', '8', '9'}; // PASSWORD E 1234 DEFINIDA AQUI!!!!
int currentLength = 0; //defines which number we are currently writing
int i = 0;
char entered[4];

int ledPin = 4; //red led
int ledPin2 = 3; //yellow led
int ledPin3 = 2; //green led

LiquidCrystal lcd(7, 8, 10, 11, 12, 13); // the pins we use on the LCD

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] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


void setup() {
  pinMode(ledPin, OUTPUT); // sets the digital pin as output
  pinMode(ledPin2, OUTPUT); // sets the digital pin as output
  pinMode(ledPin3, OUTPUT); // sets the digital pin as output
  tone1.begin(9);
  lcd.begin(16, 2);
  Serial.begin(9600);
  lcd.clear();
  lcd.setCursor(0, 0);


  lcd.print(" CODIGO ");
  while (currentLength < 4)
  {
    lcd.setCursor(currentLength + 6, 1);
    lcd.cursor();
    char key = keypad.getKey();
    key == NO_KEY;
    if (key != NO_KEY)
    {
      if ((key != '*') && (key != '#'))
      {
        lcd.print(key);
        password[currentLength] = key;
        currentLength++;
        tone1.play(NOTE_C6, 200);
      }
    }
  }

  if (currentLength == 4)
  {
    delay(500);
    lcd.noCursor();
    lcd.clear();
    lcd.home();
    lcd.print(" CONFIRMA CODIGO");
    lcd.setCursor(6, 1);
    lcd.print(password[0]);
    lcd.print(password[1]);
    lcd.print(password[2]);
    lcd.print(password[3]);

    tone1.play(NOTE_E6, 200);
    delay(3000);
    lcd.clear();
    currentLength = 0;
  }
}

void loop()
{
  timer();
  char key2 = keypad.getKey(); // get the key

  if (key2 == '*')
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CODIGO: ");

    while (currentLength < 4)
    {

      timer();

      char key2 = keypad.getKey();
      if (key2 == '#')
      {
        currentLength = 0;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Code: ");
      }
      else if (key2 != NO_KEY)
      {

        lcd.setCursor(currentLength + 7, 0);
        lcd.cursor();

        lcd.print(key2);
        entered[currentLength] = key2;
        currentLength++;
        tone1.play(NOTE_C6, 200);
        delay(100);
        lcd.noCursor();
        lcd.setCursor(currentLength + 6, 0);
        lcd.print("*");
        lcd.setCursor(currentLength + 7, 0);
        lcd.cursor();
      }
    }

    if (currentLength == 4)
    {
      if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
      {
        lcd.noCursor();
        lcd.clear();
        lcd.home();
        lcd.print ("  ");
        currentLength = 0;
        digitalWrite(ledPin3, HIGH);
        delay(2500);
        lcd.setCursor(0, 1);
        lcd.print("  ");
        delay(1000000);
      }
      else
      {
        lcd.noCursor();
        lcd.clear();
        lcd.home();
        lcd.print("  ");

        if (Hcount > 0)
        {
          Hcount = Hcount - 1;
        }

        if (Mcount > 0)
        {
          Mcount = Mcount - 59;
        }
        if (Scount > 0)
        {
          Scount = Scount - 59;
        }
        delay(1500);
        currentLength = 0;

      }
    }
  }
}

void timer()
{
  Serial.print(Scount);
  Serial.println();

  if (Hcount <= 0)
  {
    if ( Mcount < 0 )
    {
      lcd.noCursor();
      lcd.clear();
      lcd.home();
      lcd.print("    ");
      lcd.setCursor (0, 1);
      lcd.print("    ");

      while (Mcount < 0)
      {
        digitalWrite(ledPin, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin2, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin2, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin3, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin3, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
      }
    }
  }

  lcd.setCursor (0, 1); // sets cursor to 2nd line
  lcd.print ("QUEDAN:");

  if (Hcount >= 10)
  {
    lcd.setCursor (7, 1);
    lcd.print (Hcount);
  }
  if (Hcount < 10)
  {
    lcd.setCursor (7, 1);
    lcd.write ("0");
    lcd.setCursor (8, 1);
    lcd.print (Hcount);
  }

  lcd.print (":");

  if (Mcount >= 10)
  {
    lcd.setCursor (10, 1);
    lcd.print (Mcount);
  }
  if (Mcount < 10)
  {
    lcd.setCursor (10, 1);
    lcd.write ("0");
    lcd.setCursor (11, 1);
    lcd.print (Mcount);
  }

  lcd.print (":");

  if (Scount >= 10)
  {
    lcd.setCursor (13, 1);
    lcd.print (Scount);
  }
  if (Scount < 10)
  {
    lcd.setCursor (13, 1);
    lcd.write ("0");
    lcd.setCursor (14, 1);
    lcd.print (Scount);
  }

  if (Hcount < 0)
  {
    Hcount = 0;
  }

  if (Mcount < 0)
  {
    Hcount --;
    Mcount = 59;
  }

  if (Scount < 1) // if 60 do this operation
  {
    Mcount --; // add 1 to Mcount
    Scount = 59; // reset Scount
  }

  if (Scount > 0) // do this oper. 59 times
  {
    unsigned long currentMillis = millis();

    if (currentMillis - secMillis > interval)
    {
      tone1.play(NOTE_G5, 200);
      secMillis = currentMillis;
      Scount --; // add 1 to Scount
      digitalWrite(ledPin2, HIGH); // sets the LED on
      delay(10); // waits for a second
      digitalWrite(ledPin2, LOW); // sets the LED off
      delay(10); // waits for a second
      //lcd.clear();
    }
  }
}

Gracias de nuevo carmeloco,ahora mirare tu código con el anterior y hare comparaciones,aunque ahora me da este error pero es cosa de la librería será cambiarla o anularla.

Arduino:1.6.3 (Windows 7), Placa:"Arduino Uno"

Opciones de compilación cambiadas, reconstruyendo todo
i2c_carmeloco.ino:26:1: error: 'LiquidCrystal' does not name a type
Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias

Has instalado la librería de fmalpartida que te dije? Te vuelvo a poner el link:

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip

Recuerda que cuando la instales, el nombre del directorio donde la descomprimas se llame LiquidCrystal_I2C

si la descargue,e compìlado para ver si compilaba y solo me da ese error de eso ya se yo "apañarme" de nuevo muchas gracias.

Ya, pero es extraño, a mi no me da ese error. A mi solo me da error de la libreria tone, porque no la tengo.

pues si la verdad es que me esta dando mucha guerra me da este error:

Arduino:1.6.3 (Windows 7), Placa:"Arduino Uno"

_i2c_carmeloco.ino:2:31: fatal error: LiquidCrystal_I2C.h: No such file or directory

compilation terminated.

Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias

e echo lo que ,me has dicho,si pongo la librería liquidcrystal me da este otro:

Arduino:1.6.3 (Windows 7), Placa:"Arduino Uno"

_i2c_carmeloco.ino:26:1: error: 'LiquidCrystal' does not name a type

Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias

lo mas curioso es que tengo este otro código que funciona con i2c también y me compila y funciona perfectamente:

#include <Keypad.h>

#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>


#include <Wire.h> 
#include <Keypad.h>
//#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal.h>
/*
 Arduino Bomb Pro
 
 The circuit:
 * More info at : http://yin.mainstreamds.com/
 If you need some help mail me to yinbot@gmail.com
 
 created 4,Sep, 2010
 Modified 24 May 2014
 by Ignacio Lillo
 
 */

//LiquidCrystal_I2C lcd(0x38,16,2);
LiquidCrystal_I2C lcd(0x27, 2,1,0,4,5,6,7,3, POSITIVE);
const byte rows = 4; //four rows
const byte cols = 4; //four columns
char keys[rows][cols] = {
  {
    '1','2','3','a'                          }
  ,
  {
    '4','5','6','b'                          }
  ,
  {
    '7','8','9','c'                          }
  ,
  {
    '*','0','#','d'                          }
};
byte rowPins[rows] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[cols] = {2, 3, 4, 5}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );



char enteredText[8];
byte time[4];
byte refresh=0;//1 if is refreshed once time...
char password[8];
int key=-1;
char lastKey;
char var;
boolean passwordEnable=false;

//Buttons for lcd shield
char BT_RIGHT = '4';
char BT_UP = 'a';
char BT_DOWN = 'b';
char BT_LEFT = '6';
char BT_SEL = 'd';   // Ok key  
char BT_CANCEL = 'c';
char BT_DEFUSER = 'x';   // not implemented

//leds

const int REDLED = 12;
const int GREENLED = 11;
//const int BLUELED = 12;
//mosfet
boolean mosfetEnable = false;
const int mosfet = 10;
//IS VERY IMPORTANT THAT YOU TEST THIS TIME. BY DEFAULT IS IN 1 SEC. THAT IS NOT TOO MUCH. SO TEST IT!
const int MOSFET_TIME = 5000;

//TIME INTS
int GAMEHOURS = 0;
int GAMEMINUTES = 45;
int BOMBMINUTES = 4;
int ACTIVATESECONDS = 5;

boolean endGame = false;

boolean sdStatus = false; //search and destroy game enable used in config
boolean saStatus = false; //same but SAbotaghe
boolean doStatus = false; //for DEmolition
boolean start = true;
boolean defuseando;
boolean cancelando;
// SOUND TONES
boolean soundEnable = true;
int tonepin = 13; // Pin 13 for the sound
int tonoPitido = 3000;
int tonoAlarma1 = 700;
int tonoAlarma2 = 2600;
int tonoActivada = 1330;
int errorTone = 100;

unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long greenTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = green team, 2 = red team

void setup(){
  lcd.begin(16, 2);
  Serial.begin(9600);
  //  lcd.init();                      // initialize the lcd 
  //  lcd.backlight();
  lcd.setCursor(2,0);
  tone(tonepin,2400,30);
  lcd.print("BATLLEGROUND");// you can add your team name or someting cool
  lcd.setCursor(4,1);
  lcd.print("AIRSOFT");// you can add your team name or someting cool
  keypad.setHoldTime(50);
  keypad.setDebounceTime(50);
  keypad.addEventListener(keypadEvent);
  delay(2000);
  pinMode(GREENLED, OUTPUT);     
//  pinMode(8, OUTPUT);  
//  digitalWrite(8,HIGH);
  pinMode(REDLED, OUTPUT); 
  pinMode(mosfet, OUTPUT);  
  // CONFIGURE THE BARS OF PROGRESS BAR
  byte bar1[8] = {
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
  };
  byte bar2[8] = {
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
  };
  byte bar3[8] = {
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
  };
  byte bar4[8] = {
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
  };
  byte bar5[8] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
  };
  byte up[8] = {
    B00000,
    B00100,
    B01110,
    B11111,
    B11111,
    B00000,
    B00000,
  };

  byte down[8] = {
    B00000,
    B00000,
    B11111,
    B11111,
    B01110,
    B00100,
    B00000,
  };
  lcd.createChar(0,bar1);
  lcd.createChar(1,bar2);
  lcd.createChar(2,bar3);
  lcd.createChar(3,bar4);
  lcd.createChar(4,bar5);
  lcd.createChar(5,up);
  lcd.createChar(6,down);
}

void loop(){
  menuPrincipal();
}
void keypadEvent(KeypadEvent key){
  switch (keypad.getState()){
    case PRESSED:
      switch (key){

      }
    break;
    case RELEASED:
      switch (key){
         case 'd': defuseando= false;
         //Serial.println("d Releases");
         break;
         case 'c': cancelando=false;
         //Serial.println("c Releases");
         break;
      }
    break;
    case HOLD:
      switch (key){
        case 'd': defuseando= true;
        //Serial.println("d hold");
        break;
        case 'c': cancelando=true;
        //Serial.println("c hold");
        break;
      }
    break;
  }
}

void disarmedSplash(){
  endGame = false;
  digitalWrite(REDLED, LOW); 
  digitalWrite(GREENLED, LOW);
  if(sdStatus || saStatus){
    lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("DESACTIVADO");
    lcd.setCursor(3,1);
    lcd.print(" ");
    digitalWrite(GREENLED, HIGH);  
    delay(5000);
    digitalWrite(GREENLED, LOW); 
  }
  //end code
  lcd.clear();
  lcd.print(" ");
  lcd.setCursor(0,1);
  lcd.print("A : SI B : NO ");
  digitalWrite(REDLED, LOW);  
  digitalWrite(GREENLED, LOW); 
  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      tone(tonepin,2400,30);
      //We have two options, search & destroy and sabotaje play again options so!
      if(sdStatus){
        startGameCount();
        search();
      }
      if(saStatus){
        saStatus=true;
        startGameCount();
        start=true; //to set iTime to actual millis() :D
        sabotage();
      }
    }  
    if(var == 'b' ){
      tone(tonepin,2400,30);
      menuPrincipal();
      break;
    }  
  } 
}

void explodeSplash(){
  digitalWrite(REDLED, LOW);  
  digitalWrite(GREENLED, LOW); 
  cls();
  delay(100);
  endGame = false;
  lcd.setCursor(3,0);
  lcd.print(" ");
  lcd.setCursor(2,1);
  lcd.print(" ");
  for(int i = 200; i>0; i--)// this is the ultra hi definition explosion sound xD
  {
    tone(tonepin,i);
    delay(20);
  }
  noTone(tonepin);
  if(mosfetEnable){
    activateMosfet(); 
  }
  delay(5000);
  cls();

  //end code
  lcd.print(" ");
  lcd.setCursor(0,1);
  lcd.print("A : SI B : NO");
  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      tone(tonepin,2400,30);
      //We have two options, search & destroy and sabotaje play again options so!
      if(sdStatus){
        startGameCount();
        search();
      }
      if(saStatus){
        saStatus=true;
        startGameCount();
        start=true; //to set iTime to actual millis() :D
        sabotage();
      }
    }  
    if(var == 'b' ){
      tone(tonepin,2400,30);
      menuPrincipal();

      break;
    }  
  } 
}

Hola nuken, respondes que la has descargado, ¿le has cambiado el nombre una vez instalada como te dicen arriba?
Un saludo.

Hola xtrem3,si lo e echo varias veces y cambiado el directorio,lo e descomprimido y despues cambiado el nombre,lo e metido en documentos-arduino- librerias me daba ese error,luego lo quite y lo meti archivos de programa-arduino- librerias y tampoco,ya no se que estoy haciendo mal,gracias por vuestra paciencia que no es poca.

estas son las librerías que tengo:

El problema que tienes supongo que es la version del IDE (supongo y lo vuelvo a resaltar).
Prueba con la versión 1.6.0
Estas con la 1.6.3

Si tienes otra computadora intenta una instalación limpia con la 1.6.0 y no subas de versión a menos que sea estrictamente necesario.

Gracias por tu aporte surbyte e cambiado el IDE al 1.6.0 y me da este otro error bueno quizás sea mi suerte quien sabe jugare la lotería esta semana afortunado en amores no seré pero problemático...en fin...

Arduino:1.6.0 (Windows 7), Placa:"Arduino Uno"

i2c_carmeloco.ino:26:1: error: 'LiquidCrystal' does not name a type
Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias

BUeno tambien como a carmeloco me da error porque no tengo tone.h pero agregué
#include <Wire.h> y compila hasta ahi

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#include <Tone.h>
#define pound 14

Se comprende. No tengo la librería Tone.h y no me interesa por el momento.

A mi me funciona la libreria LiquidCrystal_I2C con el ide 1.6.5.

Gracias chicos por vuestro interés pero ya no os quiero volver majaras,lo estraño es que si me funciona otro código con i2c eso es lo que mas rabia me da, el segundo código va de lujo con i2c será cosa mia,mira que e borrado las librerías y dejar todo sin liquidcrystal y luego e vuelto a instalar otra vez y muy despacio y con tranquilidad,me comeré el tarro y le pondré su pontenciometro tan bonito acompañado de sus 12 cablecitos la lata que me dara será tremenda pero es lo que hay lo dejo por imposible quizás cuando este mas fresco otro dia,lo dicho gracias por vuestra amabilidad a todos.

nuken, prueba este código:

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#include <Tone.h>
#define pound 14

Tone tone1;

int Scount = 60; // count seconds
int Mcount = 1; // count minutes
int Hcount = 0; // count hours
int DefuseTimer = 0; // set timer to 0

long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds

char password[4] = {'0', '4', '8', '9'}; // PASSWORD E 1234 DEFINIDA AQUI!!!!
int currentLength = 0; //defines which number we are currently writing
int i = 0;
char entered[4];

int ledPin = 4; //red led
int ledPin2 = 3; //yellow led
int ledPin3 = 2; //green led

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] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  pinMode(ledPin, OUTPUT); // sets the digital pin as output
  pinMode(ledPin2, OUTPUT); // sets the digital pin as output
  pinMode(ledPin3, OUTPUT); // sets the digital pin as output
  tone1.begin(9);
  lcd.begin(16, 2);
  Serial.begin(9600);
  lcd.clear();
  lcd.setCursor(0, 0);

  lcd.print(" CODIGO ");
  while (currentLength < 4)
  {
    lcd.setCursor(currentLength + 6, 1);
    lcd.cursor();
    char key = keypad.getKey();
    key == NO_KEY;
    if (key != NO_KEY)
    {
      if ((key != '*') && (key != '#'))
      {
        lcd.print(key);
        password[currentLength] = key;
        currentLength++;
        tone1.play(NOTE_C6, 200);
      }
    }
  }

  if (currentLength == 4)
  {
    delay(500);
    lcd.noCursor();
    lcd.clear();
    lcd.home();
    lcd.print(" CONFIRMA CODIGO");
    lcd.setCursor(6, 1);
    lcd.print(password[0]);
    lcd.print(password[1]);
    lcd.print(password[2]);
    lcd.print(password[3]);

    tone1.play(NOTE_E6, 200);
    delay(3000);
    lcd.clear();
    currentLength = 0;
  }
}

void loop()
{
  timer();
  char key2 = keypad.getKey(); // get the key

  if (key2 == '*')
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CODIGO: ");

    while (currentLength < 4)
    {

      timer();

      char key2 = keypad.getKey();
      if (key2 == '#')
      {
        currentLength = 0;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Code: ");
      }
      else if (key2 != NO_KEY)
      {

        lcd.setCursor(currentLength + 7, 0);
        lcd.cursor();

        lcd.print(key2);
        entered[currentLength] = key2;
        currentLength++;
        tone1.play(NOTE_C6, 200);
        delay(100);
        lcd.noCursor();
        lcd.setCursor(currentLength + 6, 0);
        lcd.print("*");
        lcd.setCursor(currentLength + 7, 0);
        lcd.cursor();
      }
    }

    if (currentLength == 4)
    {
      if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
      {
        lcd.noCursor();
        lcd.clear();
        lcd.home();
        lcd.print ("  ");
        currentLength = 0;
        digitalWrite(ledPin3, HIGH);
        delay(2500);
        lcd.setCursor(0, 1);
        lcd.print("  ");
        delay(1000000);
      }
      else
      {
        lcd.noCursor();
        lcd.clear();
        lcd.home();
        lcd.print("  ");

        if (Hcount > 0)
        {
          Hcount = Hcount - 1;
        }

        if (Mcount > 0)
        {
          Mcount = Mcount - 59;
        }
        if (Scount > 0)
        {
          Scount = Scount - 59;
        }
        delay(1500);
        currentLength = 0;

      }
    }
  }
}

void timer()
{
  Serial.print(Scount);
  Serial.println();

  if (Hcount <= 0)
  {
    if ( Mcount < 0 )
    {
      lcd.noCursor();
      lcd.clear();
      lcd.home();
      lcd.print("    ");
      lcd.setCursor (0, 1);
      lcd.print("    ");

      while (Mcount < 0)
      {
        digitalWrite(ledPin, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin2, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin2, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin3, HIGH); // sets the LED on
        tone1.play(NOTE_A2, 90);
        delay(100);
        digitalWrite(ledPin3, LOW); // sets the LED off
        tone1.play(NOTE_A2, 90);
        delay(100);
      }
    }
  }

  lcd.setCursor (0, 1); // sets cursor to 2nd line
  lcd.print ("QUEDAN:");

  if (Hcount >= 10)
  {
    lcd.setCursor (7, 1);
    lcd.print (Hcount);
  }
  if (Hcount < 10)
  {
    lcd.setCursor (7, 1);
    lcd.write ("0");
    lcd.setCursor (8, 1);
    lcd.print (Hcount);
  }

  lcd.print (":");

  if (Mcount >= 10)
  {
    lcd.setCursor (10, 1);
    lcd.print (Mcount);
  }
  if (Mcount < 10)
  {
    lcd.setCursor (10, 1);
    lcd.write ("0");
    lcd.setCursor (11, 1);
    lcd.print (Mcount);
  }

  lcd.print (":");

  if (Scount >= 10)
  {
    lcd.setCursor (13, 1);
    lcd.print (Scount);
  }
  if (Scount < 10)
  {
    lcd.setCursor (13, 1);
    lcd.write ("0");
    lcd.setCursor (14, 1);
    lcd.print (Scount);
  }

  if (Hcount < 0)
  {
    Hcount = 0;
  }

  if (Mcount < 0)
  {
    Hcount --;
    Mcount = 59;
  }

  if (Scount < 1) // if 60 do this operation
  {
    Mcount --; // add 1 to Mcount
    Scount = 59; // reset Scount
  }

  if (Scount > 0) // do this oper. 59 times
  {
    unsigned long currentMillis = millis();

    if (currentMillis - secMillis > interval)
    {
      tone1.play(NOTE_G5, 200);
      secMillis = currentMillis;
      Scount --; // add 1 to Scount
      digitalWrite(ledPin2, HIGH); // sets the LED on
      delay(10); // waits for a second
      digitalWrite(ledPin2, LOW); // sets the LED off
      delay(10); // waits for a second
      //lcd.clear();
    }
  }
}

He encontrado un error, había una línea de más, que hacía referencia al antiguo LCD, y faltaba la llamada a la librería wire.

Gracias de nuevo e probado tu código carmeloco,me pedia la librería tone y la tengo y me da este otro enésimo error.

Arduino:1.6.0 (Windows 7), Placa:"Arduino Uno"

C:\Users\Documents\Arduino\libraries\Tone\Tone.cpp:26:20: fatal error: wiring.h: No such file or directory
#include <wiring.h>
^
compilation terminated.
Error de compilación

This report would have more information with
"Show verbose output during compilation"
activala desde Archivo > Preferencias