Rf Link using virtualwire and LCD with softwareserial

Hello, first of all this is my first post, be gentle :wink:

So, i have a serial enabled lcd that i run on my arduino using softwareserial in pin 2 and it works fine. I need to send some information using this RF link: http://www.sparkfun.com/products/10534

and for that was going to use the virtualwire library on pin 3.

The problem is, as soon as i upload my new code with the virtualwire, the LCD goes crazy. Im thinking that for some reason its not possible to use virtualwire and softwareserial together.

i tried using softwareserial on other pins, and using the virtualwire in other pins. Didn’t work.

Here is my original code:

The only difference is basically on the setup function.

#include <Keypad.h>
#include <SoftwareSerial.h> 
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //RTC adress on I2C bus

///////////////////////////////////////////////sofware serial setup for LCD
#define txPin1 2
SoftwareSerial LCD = SoftwareSerial(0, txPin1);

////////////////////////////////////////////////////////INITIAL KEYPAD SETUP:
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] = {
  9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  12, 11, 10}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
///////////////////////////////////////////////////////////////////////////////Address:
byte add[3]={1,2,3}; //Direcciones de los dispositivos
                    //1--> MASTER ADRESS
                    //2-->Send to ALL
                    //3-->Send to Slave 1
byte tip[7]={17,18,20,24,33,34,36};
///////////////////////////////////////////////////////////////////////////////////FUNCTIONS CLOCK:
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
  return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
  return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second,        // 0-59
byte minutes,        // 0-59
byte hour,          // 1-23
byte dayOfWeek,     // 1-7
byte dayOfMonth,    // 1-28/29/30/31
byte month,         // 1-12
byte year)          // 0-99
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock
  Wire.send(decToBcd(minutes));
  Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                  // bit 6 (also need to change readDateDs1307)
  Wire.send(decToBcd(dayOfWeek));
  Wire.send(decToBcd(dayOfMonth));
  Wire.send(decToBcd(month));
  Wire.send(decToBcd(year));
  Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minutes,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.receive() & 0x7f);
  *minutes     = bcdToDec(Wire.receive());
  *hour       = bcdToDec(Wire.receive() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.receive());
  *dayOfMonth = bcdToDec(Wire.receive());
  *month      = bcdToDec(Wire.receive());
  *year       = bcdToDec(Wire.receive());
}
//////////////////////////////////////////////////LCD CONTROL
void clearLCD(){
  LCD.print(0xFE, BYTE); //command flag 
  LCD.print(0x01, BYTE); //clear command.
}

void pointer1(){ //Line 1 on the LCD cursor
  LCD.print(0xFE, BYTE);
  LCD.print(128, BYTE);
}

void pointer2(){ //Line 2 on the LCD cursor
  LCD.print(0xFE, BYTE);
  LCD.print(192, BYTE);
}

void backlightON(){
  LCD.print(0x7C, BYTE); //command flag for backlight 
  LCD.print(140, BYTE);	 //light level.
}
void backlightOFF(){     //turns off the backlight
  LCD.print(0x7C, BYTE);	
  LCD.print(128, BYTE);	//light level for off.
}
void displayoff(){ //Turns display off
  LCD.print(0xFE, BYTE);
  LCD.print(0x08, BYTE);
}
void displayon(){ //Tunrs display back on
  LCD.print(0xFE, BYTE);
  LCD.print(0x0C, BYTE);
}

//////////////////////////////////////////////////////////Variables gets. keypad and conversion
                                                         //to valid values  (translate function)
int traduc(char val){
  switch (val){
  case 48:
  return(0);
  break;
  case 49:
  return(1);
  break;
  case 50:
  return(2);
  break;
  case 51:
  return(3);
  break;
  case(52):
  return(4);
  break;
  case(53):
  return(5);
  break;
  case(54):
  return(6);
  break;
  case(55):
  return(7);
  break;
  case 56:
  return(8);
  break;
  case 57:
  return(9);
  break;
 
  }
  ////////////////////////////////////////FUNCION SEGUNDOS
}
int asksecond(){
inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Seconds? 00-59");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
  
  int total=aux1+aux2;
  if(total>59){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  
  return(aux1+aux2);
  }
  //////////////////////////////////////////////FUNCION MINUTOS
int askminutes(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Minutes? 00-59");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>59){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  /////////////////////////////////////////////////FUNCION HORA
int askhour(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Hour? 00-23");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>23){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ///////////////////////////////////////FUNCION DIASEMANA
int askdayofweek(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("DayOfWeek? 01-07");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>7 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ///////////////////////////////////////FUNCION AÑO
int askyear(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Year? 00-99");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>99){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ////////////////////////////////////////FUNCION MES
int askmonth(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Month? 01-12");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>12 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
/////////////////////////////////FUNCION DIA
  int askday(){
    inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Day? 01-31");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>31 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
//////////////////////////////////////////////////////////////initial setup, interactive
void ds1307setup(byte second,byte minutes,byte hour,byte dayOfWeek,byte dayOfMonth,byte month,byte year){
  char key;
  int i=0;
  pointer1();
  LCD.print(hour, DEC);
  LCD.print(":");
  LCD.print(minutes, DEC);
  LCD.print(":");
  LCD.print(second, DEC);
  pointer2();
  LCD.print(month, DEC);
  LCD.print("/");
  LCD.print(dayOfMonth, DEC);
  LCD.print("/");
  LCD.print(year, DEC);
  LCD.print(" Day:");
  LCD.print(dayOfWeek, DEC);
  delay(5000);
  clearLCD();
  LCD.print("Time correct?");
  pointer2();
  LCD.print("Y/N? #=YES *=NO");
  while (i==0){
    key = keypad.getKey();
    if(key == 42){
      i=1;
    }
    else if (key == 35){
      i=1;
      second = asksecond();
      minutes = askminutes();
      hour = askhour();
      dayOfWeek = askdayofweek();
      dayOfMonth = askday();
      month = askmonth();
      year = askyear();
      setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
    }
    if (millis() > 50000){ //Set desired time of initial setup
      i=1;
    }
  }  
}
///////////////////////////////////////////////////////SEND TO ALL

///////////////////////////////////////////////////////
void setup()
{
  delay(200);
  byte second, minutes, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  getDateDs1307(&second, &minutes, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  Serial.begin(9600);
  pinMode(txPin1, OUTPUT);
  
  LCD.begin(9600);    //Open LCD port on board

  backlightON();      //Initianl Backlight setup. not fixed.
  clearLCD();
  delay(25);
  /////////////////////////////////////////////////////////AJUSTE INICIAL:
  ds1307setup(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
  /////////////////////////////////////////////////////////
  // Change these values to what you want to set your clock to.
  // You probably only want to set your clock once and then remove
  // the setDateDs1307 call.
  //second = 45;
  //minutes = 40;
  //hour = 13;
  //dayOfWeek = 4;
  //dayOfMonth = 20;
  //month = 1;
  //year = 11;
  //setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
  clearLCD();
}

void loop()
{
  char key;
  byte second, minutes, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minutes, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  
/////////////////////////////////////////////////////////SERIAL PRINT OF DATA, DEBUG
  Serial.print(hour, DEC);
  Serial.print(":");
  Serial.print(minutes, DEC);
  Serial.print(":");
  Serial.print(second, DEC);
  Serial.print("  ");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print("  Day_of_week:");
  Serial.println(dayOfWeek, DEC);
  Serial.println("Ciclo completado");
///////////////////////////////////////////////////////LCD PRINTING
  pointer1();
  if (hour < 10){
    LCD.print("0");
    LCD.print(hour, DEC);
  }
  else {
    LCD.print(hour, DEC);
  }
  LCD.print(":");
  if (minutes < 10){
    LCD.print("0");
    LCD.print(minutes, DEC);
  }
  else {
    LCD.print(minutes, DEC);
  }
  LCD.print(":");
  if (second < 10){
    LCD.print("0");
    LCD.print(second, DEC);
  }
  else {
    LCD.print(second, DEC);
  }
  LCD.print("   Day:");
  pointer2();
  if (dayOfMonth < 10){
    LCD.print("0");
    LCD.print(dayOfMonth, DEC);
  }
  else {
    LCD.print(dayOfMonth, DEC);
  }
  LCD.print("/");
  if (month < 10){
    LCD.print("0");
    LCD.print(month, DEC);
  }
  else {
    LCD.print(month, DEC);
  }
  LCD.print("/");
  if (year < 10){
    LCD.print("0");
    LCD.print(year, DEC);
  }
  else {
    LCD.print(year, DEC);
  }
  LCD.print("    ");
  switch (dayOfWeek) {
  case 1:
    LCD.print("MON");
    break;
  case 2:
    LCD.print("TUE");
    break;
  case 3:
    LCD.print("WED");
    break;
  case 4:
    LCD.print("THU");
    break;
  case 5:
    LCD.print("FRI");
    break;
  case 6:
    LCD.print("SAT");
    break;
  case 7:
    LCD.print("SUN");
    break;
  }
  /////////////////////////////////////////////Posible solucion para ajuste de hora en loop
 key = keypad.getKey(); 
  if (key == 35){
      second = asksecond();
      minutes = askminutes();
      hour = askhour();
      dayOfWeek = askdayofweek();
      dayOfMonth = askday();
      month = askmonth();
      year = askyear();
      
      setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
    }
    
////////////////////////////////////////////////END OF LCD-PRINTING And interactive access on loop
/* 
H-->0x11  --> 17
M-->0x12  --> 18
S-->0x14  --> 20
D-->0x18  --> 24
M-->0x21  --> 33
Y-->0x22  --> 34
DW-->0x24  --> 36
*/

}

and the one with virtuawire:

#include <VirtualWire.h>
#include <Keypad.h>
#include <SoftwareSerial.h> 
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //RTC adress on I2C bus

///////////////////////////////////////////////sofware serial setup for LCD
#define txPin1 2
SoftwareSerial LCD = SoftwareSerial(0, txPin1);

////////////////////////////////////////////////////////INITIAL KEYPAD SETUP:
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] = {
  9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  12, 11, 10}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
///////////////////////////////////////////////////////////////////////////////Address:
byte add[3]={1,2,3}; //Direcciones de los dispositivos
                    //1--> MASTER ADRESS
                    //2-->Send to ALL
                    //3-->Send to Slave 1
byte tip[7]={17,18,20,24,33,34,36};
///////////////////////////////////////////////////////////////////////////////////FUNCTIONS CLOCK:
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
  return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
  return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second,        // 0-59
byte minutes,        // 0-59
byte hour,          // 1-23
byte dayOfWeek,     // 1-7
byte dayOfMonth,    // 1-28/29/30/31
byte month,         // 1-12
byte year)          // 0-99
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock
  Wire.send(decToBcd(minutes));
  Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                  // bit 6 (also need to change readDateDs1307)
  Wire.send(decToBcd(dayOfWeek));
  Wire.send(decToBcd(dayOfMonth));
  Wire.send(decToBcd(month));
  Wire.send(decToBcd(year));
  Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minutes,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.receive() & 0x7f);
  *minutes     = bcdToDec(Wire.receive());
  *hour       = bcdToDec(Wire.receive() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.receive());
  *dayOfMonth = bcdToDec(Wire.receive());
  *month      = bcdToDec(Wire.receive());
  *year       = bcdToDec(Wire.receive());
}
//////////////////////////////////////////////////LCD CONTROL
void clearLCD(){
  LCD.print(0xFE, BYTE); //command flag 
  LCD.print(0x01, BYTE); //clear command.
}

void pointer1(){ //Line 1 on the LCD cursor
  LCD.print(0xFE, BYTE);
  LCD.print(128, BYTE);
}

void pointer2(){ //Line 2 on the LCD cursor
  LCD.print(0xFE, BYTE);
  LCD.print(192, BYTE);
}

void backlightON(){
  LCD.print(0x7C, BYTE); //command flag for backlight 
  LCD.print(140, BYTE);	 //light level.
}
void backlightOFF(){     //turns off the backlight
  LCD.print(0x7C, BYTE);	
  LCD.print(128, BYTE);	//light level for off.
}
void displayoff(){ //Turns display off
  LCD.print(0xFE, BYTE);
  LCD.print(0x08, BYTE);
}
void displayon(){ //Tunrs display back on
  LCD.print(0xFE, BYTE);
  LCD.print(0x0C, BYTE);
}

//////////////////////////////////////////////////////////Variables gets. keypad and conversion
                                                         //to valid values  (translate function)
int traduc(char val){
  switch (val){
  case 48:
  return(0);
  break;
  case 49:
  return(1);
  break;
  case 50:
  return(2);
  break;
  case 51:
  return(3);
  break;
  case(52):
  return(4);
  break;
  case(53):
  return(5);
  break;
  case(54):
  return(6);
  break;
  case(55):
  return(7);
  break;
  case 56:
  return(8);
  break;
  case 57:
  return(9);
  break;
 
  }
  ////////////////////////////////////////FUNCION SEGUNDOS
}
int asksecond(){
inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Seconds? 00-59");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
  
  int total=aux1+aux2;
  if(total>59){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  
  return(aux1+aux2);
  }
  //////////////////////////////////////////////FUNCION MINUTOS
int askminutes(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Minutes? 00-59");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>59){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  /////////////////////////////////////////////////FUNCION HORA
int askhour(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Hour? 00-23");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>23){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ///////////////////////////////////////FUNCION DIASEMANA
int askdayofweek(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("DayOfWeek? 01-07");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>7 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ///////////////////////////////////////FUNCION AÑO
int askyear(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Year? 00-99");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>99){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
  ////////////////////////////////////////FUNCION MES
int askmonth(){
  inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Month? 01-12");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>12 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
/////////////////////////////////FUNCION DIA
  int askday(){
    inicio:
int i=0;
char aux1;
char aux2;
char aux3;
clearLCD();
pointer1();
LCD.print("Day? 01-31");
pointer2();
LCD.print("Finish-->* ");
while (i == 0){
  aux1 = keypad.getKey();
  if (aux1 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux1);
  while (i == 0){
  aux2 = keypad.getKey();
  if (aux2 != NO_KEY){
  i = 1;
    }
  }
  i=0;
  LCD.print(aux2);
 while (i==0){
    aux3 = keypad.getKey();
    if(aux3 == 35){
      i=1;
    }
 }
  delay(25);
  aux1=traduc(aux1);
  aux2=traduc(aux2);
  if (aux1>0){
   aux1=aux1*10; 
  }
    
  int total=aux1+aux2;
  if(total>31 || total<1){
    
  pointer1();
  LCD.print("    ERROR     ");

  delay(1000);
  goto inicio;
  }
  return(aux1+aux2);
  }
//////////////////////////////////////////////////////////////initial setup, interactive
void ds1307setup(byte second,byte minutes,byte hour,byte dayOfWeek,byte dayOfMonth,byte month,byte year){
  char key;
  int i=0;
  pointer1();
  LCD.print(hour, DEC);
  LCD.print(":");
  LCD.print(minutes, DEC);
  LCD.print(":");
  LCD.print(second, DEC);
  pointer2();
  LCD.print(month, DEC);
  LCD.print("/");
  LCD.print(dayOfMonth, DEC);
  LCD.print("/");
  LCD.print(year, DEC);
  LCD.print(" Day:");
  LCD.print(dayOfWeek, DEC);
  delay(5000);
  clearLCD();
  LCD.print("Time correct?");
  pointer2();
  LCD.print("Y/N? #=YES *=NO");
  while (i==0){
    key = keypad.getKey();
    if(key == 42){
      i=1;
    }
    else if (key == 35){
      i=1;
      second = asksecond();
      minutes = askminutes();
      hour = askhour();
      dayOfWeek = askdayofweek();
      dayOfMonth = askday();
      month = askmonth();
      year = askyear();
      setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
    }
    if (millis() > 50000){ //Set desired time of initial setup
      i=1;
    }
  }  
}

///////////////////////////////////////////////////////
void setup()
{
  delay(200);
  byte second, minutes, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  getDateDs1307(&second, &minutes, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  Serial.begin(9600);
  pinMode(txPin1, OUTPUT);
  pinMode(13, OUTPUT); //Alarm LED on pin 13
  LCD.begin(9600);    //Open LCD port on board
  backlightON();      //Initianl Backlight setup. not fixed.
  clearLCD();
  delay(25);
  vw_set_tx_pin(3);
  vw_setup(2000); //Starts the virtualWire
  /////////////////////////////////////////////////////////AJUSTE INICIAL:
  ds1307setup(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
  /////////////////////////////////////////////////////////
  // Change these values to what you want to set your clock to.
  // You probably only want to set your clock once and then remove
  // the setDateDs1307 call.
  //second = 45;
  //minutes = 40;
  //hour = 13;
  //dayOfWeek = 4;
  //dayOfMonth = 20;
  //month = 1;
  //year = 11;
  //setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
  clearLCD();
}

void loop()
{
  char key;
  byte second, minutes, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minutes, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  
/////////////////////////////////////////////////////////SERIAL PRINT OF DATA, DEBUG
  Serial.print(hour, DEC);
  Serial.print(":");
  Serial.print(minutes, DEC);
  Serial.print(":");
  Serial.print(second, DEC);
  Serial.print("  ");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print("  Day_of_week:");
  Serial.println(dayOfWeek, DEC);
  Serial.println("Ciclo completado");
///////////////////////////////////////////////////////LCD PRINTING
  pointer1();
  if (hour < 10){
    LCD.print("0");
    LCD.print(hour, DEC);
  }
  else {
    LCD.print(hour, DEC);
  }
  LCD.print(":");
  if (minutes < 10){
    LCD.print("0");
    LCD.print(minutes, DEC);
  }
  else {
    LCD.print(minutes, DEC);
  }
  LCD.print(":");
  if (second < 10){
    LCD.print("0");
    LCD.print(second, DEC);
  }
  else {
    LCD.print(second, DEC);
  }
  LCD.print("   Day:");
  pointer2();
  if (dayOfMonth < 10){
    LCD.print("0");
    LCD.print(dayOfMonth, DEC);
  }
  else {
    LCD.print(dayOfMonth, DEC);
  }
  LCD.print("/");
  if (month < 10){
    LCD.print("0");
    LCD.print(month, DEC);
  }
  else {
    LCD.print(month, DEC);
  }
  LCD.print("/");
  if (year < 10){
    LCD.print("0");
    LCD.print(year, DEC);
  }
  else {
    LCD.print(year, DEC);
  }
  LCD.print("    ");
  switch (dayOfWeek) {
  case 1:
    LCD.print("MON");
    break;
  case 2:
    LCD.print("TUE");
    break;
  case 3:
    LCD.print("WED");
    break;
  case 4:
    LCD.print("THU");
    break;
  case 5:
    LCD.print("FRI");
    break;
  case 6:
    LCD.print("SAT");
    break;
  case 7:
    LCD.print("SUN");
    break;
  }
  /////////////////////////////////////////////Posible solucion para ajuste de hora en loop
 key = keypad.getKey(); 
  if (key == 35){
      second = asksecond();
      minutes = askminutes();
      hour = askhour();
      dayOfWeek = askdayofweek();
      dayOfMonth = askday();
      month = askmonth();
      year = askyear();
      
      setDateDs1307(second, minutes, hour, dayOfWeek, dayOfMonth, month, year);
    }
    
////////////////////////////////////////////////END OF LCD-PRINTING And interactive access on loop
/* 
H-->0x11  --> 17
M-->0x12  --> 18
S-->0x14  --> 20
D-->0x18  --> 24
M-->0x21  --> 33
Y-->0x22  --> 34
DW-->0x24  --> 36
*/
  byte trans[2]={17,second};
  vw_send((uint8_t *)trans, sizeof(trans));
}

Thank you in advance!

Hi there,

Did you find an answer to this as I seem to be experiencing the same issue.

Trying to use a Sparkfun LCD backpack with a RF 433 receiver and the two Arduino libraries Virtualwire & SoftwareSerial.

Many thanks,

Steve