Problem with LiquidCrystal and VirtualWire compatibility

The two libraries do not work together. As soon as I use "vw_setup(2000);" LCD screen no longer works. I can't find a solution. It gives me weird characters

#include <VirtualWire.h>
#include <LiquidCrystal.h>

#define TxPin 12

LiquidCrystal lcd(5, 6, 8, 9, 10, 11);

void Demarage() {
  int i = 0;
  int j = 0;
  int k =0;
  bool Start =true;
  while (Start) {

    j++;

    if (j > 3) {
      i++;
      j=0;
    }
  
    if (i>16) {
      i=0;
      k++;
    }

    if (k > 1) {
      k=0;
      Start=false;
      lcd.clear();
    }
  
    delay(50);
    lcd.clear();
    lcd.setCursor(i, k);
    lcd.print("Demarage");  
  }
}

void setup()
{
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  lcd.begin(16, 2);
  pinMode(6, OUTPUT);
  pinMode(12, INPUT);

  Demarage();
  
  Serial.begin(9600);
  
  lcd.clear();
  
  lcd.setCursor(0, 0);
  lcd.print("Loic  V1"); // Before
     
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);  // Bits per sec
  lcd.setCursor(0, 1);
lcd.print("Loic  V1"); // After, but no working
}




void loop() {
 
    
  int y = analogRead(A0);
  int x = analogRead(A1);

  int int_x = x/4;
  int int_y = y/4;

  char x_String[4] = {'N','N','N','\0'};
  char y_String[4] = {'N','N','N','\0'};
  sprintf(x_String,"%d", int_x );
  sprintf(y_String,"%d", int_y );


  char msg[8]={'N','N','N','I','N','N','N','\0'};


  if (int_x < 10) {
      msg[0]=x_String[0];
  }
  if (int_x < 100 && int_x >= 10 ) {
      msg[0]=x_String[0];
      msg[1]=x_String[1];
  }
  if (int_x < 1000 && int_x >= 100 ) {
      msg[0]=x_String[0];
      msg[1]=x_String[1];
      msg[2]=x_String[2];
  }


  if (int_y < 10) {
      msg[4]=y_String[0];
  }
  if (int_y < 100 && int_y >= 10 ) {
      msg[4]=y_String[0];
      msg[5]=y_String[1];
  }
  if (int_y < 1000 && int_y >= 100 ) {
      msg[4]=y_String[0];
      msg[5]=y_String[1];
      msg[6]=y_String[2];
  }
  Serial.println(msg);
 
  digitalWrite(3, true); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(3, false);
  delay(50);
}

Could you help me ?

One solution could be using an I2C communicating LCD. Then You can drop the LiquidCrystal.lib.
Here are the lines doing the job:

//I2C for LCD
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

hd44780_I2Cexp mylcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
#define LCD_COLS 20
#define LCD_ROWS 4

I think that you have a pin conflict with pin 11.

Virtual Wire default Tx pin = 12 default Rx pin = 11
LiquidCrystal lcd(5, 6, 8, 9, 10, 11);

YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSS, it works ! I just needed to stop using the 11 pins as you said. Thank youuuu. My car will have a beautiful screen thanks to you.

Thanks dude, but the solution of cattledog works a lot. I like you profil picture ; )

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.