LCD it does not display anything in the loop when i us the 433Mhz

//receiver

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <VirtualWire.h>

LiquidCrystal_I2C lcd(0x27,16,2); 

int i;

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

void setup()
{
  Serial.begin(9600);
vw_setup(2000);                 
vw_set_rx_pin(11);                
vw_rx_start(); 

//int total = S1+S2+S3+S4;
//slot = slot-total; 

 lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();  
lcd.setCursor (0,0);
lcd.print("  Car  parking  ");
lcd.setCursor (0,1);
lcd.print("    System     ");
delay (200);
lcd.clear();  
lcd.setCursor (0,0);
lcd.print(" Have Slot: "); 
lcd.print(4);
lcd.print("    ");   
delay (200);    
lcd.clear();               
}
void loop()
{
lcd.setCursor (0,0);
lcd.print("S1: ");
lcd.setCursor(8,0);
lcd.print("S2: ");
Serial.println("000");

if (vw_get_message(buf, &buflen))
{
  for (i = 0; i < buflen; i++)
{  
   Serial.write(buf[i]);
}



lcd.setCursor(0,3);
if(strcmp("ledblan", (char*)buf) == 0)
{lcd.print("Fill");
Serial.println("S1:1");  
                              }
else{
lcd.print("Empty");
Serial.println("S1:0");
                                  }


lcd.setCursor(0,11);
if(strcmp("ledblan2", (char*)buf) == 0)
{lcd.print("Fill");
Serial.println("S2:1"); 
                           }
else{
lcd.print("Empty");
Serial.println("S2:0");
                           }

}
delay(200);
}saisissez ou collez du code ici
// transmitter
#include <VirtualWire.h>


#define ir_car1 5
#define ir_car2 6
#define ir_car3 7
#define ir_car4 8

int S1=0, S2=0, S3=0, S4=0;
int flag1=0, flag2=0; 
int slot = 4;  

void setup()
{
 Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(12);
pinMode(ir_car1, INPUT);
pinMode(ir_car2, INPUT);
pinMode(ir_car3, INPUT);
pinMode(ir_car4, INPUT);

int total = S1+S2+S3+S4;
slot = slot-total; 

}

void loop()
{
S1 = digitalRead(ir_car1);
S2 = digitalRead(ir_car2);
S3 = digitalRead(ir_car3);
S4 = digitalRead(ir_car4);
if(S1==1)
{
const char *msg = "ledblan";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S1:Fill");
}
else {
  const char *msg = "ledblan1";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S1:Empty");
}
if(S2==1)
{
const char *msg = "ledblan2";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S2:Fill");
}
else {
  const char *msg = "ledblan3";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S2:Empty");
}

delay(200);
}


Please read and understand

@elkalai, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project. Again, see About the Installation & Troubleshooting category.

Did you test the LCD by itself using example code form the LiquidCrystal library examples?

Have you tried the contrast adjustment?

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

I tried your transmit and receive code on the setup from your "RF communication problem betwwen ultrsonic and servo motor" post with the receiver connected to pin 11 and an I2C LCD connected. When I run the code I get "S1: S2: " displayed on the top row of the LCD.

If I set S1 = 1 in the transmit code I get the "S1: S2: " in the top row and "Empty" in the bottom row.

So the radios, code and LCD all seem to be working for me.

Thanks, bro this is the second time you help my.

What's the point of this? You never use 'total' again. Why not:

slot = slot - (S1+S2+S3+S4);

?

thanks .The code is not complete. I will use it in the sequel to another topic

The purpose is the calculation of empty and fill space .If you have ideas about displaying in the LCD screen

Is the problem solved? If so, what was the solution?

You only do it once, in setup(). All the variables S1...S4 are initialized to zero at that point.

The solution I was expecting, I did not get it. If you have any suggestions



, please help

// transmitter
#include <VirtualWire.h>


#define ir_car1 5
#define ir_car2 6
#define ir_car3 7
#define ir_car4 8

int S1=0, S2=0, S3=0, S4=0;
int flag1=0, flag2=0; 
int slot = 4;  

void setup()
{
 Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(12);
pinMode(ir_car1, INPUT);
pinMode(ir_car2, INPUT);
pinMode(ir_car3, INPUT);
pinMode(ir_car4, INPUT);




}

void loop()
{
S1 = digitalRead(ir_car1);
S2 = digitalRead(ir_car2);
S3 = digitalRead(ir_car3);
S4 = digitalRead(ir_car4);
if(S1==1)
{
  const char *msg = "Empty1";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S1:Empty");

}
else {
 const char *msg = "Fill1";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S1:Fill");
}
if(S2==1)
{
 const char *msg = "Empty2";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S2:Empty");
}
else {
  const char *msg = "Fill2";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S2:Fill");
 
}
if(S3==1)
{
 const char *msg = "Empty3";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S3:Empty");
}
else {
  const char *msg = "Fill3";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S3:Fill");
 
}
if(S4==1)
{
 const char *msg = "Empty4";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S4:Empty");
}
else {
  const char *msg = "Fill4";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S4:Fill");
 
}

delay(200);
}

//receiver

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <VirtualWire.h>

LiquidCrystal_I2C lcd(0x27,16,2);

int i;

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

void setup()
{
Serial.begin(9600);
vw_setup(2000);
vw_set_rx_pin(11);
vw_rx_start();

//int total = S1+S2+S3+S4;
//slot = slot-total;

lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor (0,0);
lcd.print(" Car parking ");
lcd.setCursor (0,1);
lcd.print(" System ");
delay (2000);
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" Have Slot: ");
lcd.print(4);
lcd.print(" ");
delay (2000);
lcd.clear();
}
void loop()
{

Serial.println("000");

if (vw_get_message(buf, &buflen))
{
for (i = 0; i < buflen; i++)
{
Serial.write(buf[i]);
}

lcd.setCursor(0,0);
if(strcmp("Empty1", (char*)buf) == 0)
{lcd.print("S1:Empty");
Serial.println("S1:0");
}
else{
lcd.print("S1:Fill");
Serial.println("S1:1");
}

lcd.setCursor(8,0);
if(strcmp("Empty2", (char*)buf) == 0)
{lcd.print("S2:Empty");
Serial.println("S2:0");
}
else{
lcd.print("S2:Fill");
Serial.println("S2:1");
}
lcd.setCursor(0,1);
if(strcmp("Empty3", (char*)buf) == 0)
{lcd.print("S3:Empty");
Serial.println("S3:0");
}
else{
lcd.print("S3:Fill");
Serial.println("S3:1");
}

lcd.setCursor(8,1);
if(strcmp("Empty4", (char*)buf) == 0)
{lcd.print("S4:Empty");
Serial.println("S4:0");
}
else{
lcd.print("S4:Fill");
Serial.println("S4:1");
}
}

delay(200);
}

You forgot to format using ctrl-T in the IDE and then post using code tags. You have two sketches, so put each one in separate code tags.

Also we need a more detailed update than, "I didn't get the results I was expecting".

Your code is not self-explanatory. Could you please post a plain language explanation of how it works, or some pseudocode?

my goal is to communicate with 433Mhz and the subject I am working on is the parking system so LCD I want to put it in the car and outside I put the infrared to detect if there is an empty space

Right now just infrared 4 it's works.

// transmitter
#include <VirtualWire.h>


#define ir_car1 5
#define ir_car2 6
#define ir_car3 7
#define ir_car4 8

int S1=0, S2=0, S3=0, S4=0;
int flag1=0, flag2=0; 
int slot = 4;  

void setup()
{
 Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(12);
pinMode(ir_car1, INPUT);
pinMode(ir_car2, INPUT);
pinMode(ir_car3, INPUT);
pinMode(ir_car4, INPUT);

int total = S1+S2+S3+S4;
slot = slot-total; 

}

void loop()
{
S1 = digitalRead(ir_car1);
S2 = digitalRead(ir_car2);
S3 = digitalRead(ir_car3);
S4 = digitalRead(ir_car4);
if(S1==1)
{
  const char *msg = "Empty1";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S1:Empty");

}
else {
 const char *msg = "Fill1";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S1:Fill");
}
if(S2==1)
{
 const char *msg = "Empty2";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S2:Empty");
}
else {
  const char *msg = "Fill2";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S2:Fill");
 
}
if(S3==1)
{
 const char *msg = "Empty3";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S3:Empty");
}
else {
  const char *msg = "Fill3";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S3:Fill");
 
}
if(S4==1)
{
 const char *msg = "Empty4";
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  Serial.println("S4:Empty");
}
else {
  const char *msg = "Fill4";
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println("S4:Fill");
 
}

delay(1000);
}
//receiver

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <VirtualWire.h>

LiquidCrystal_I2C lcd(0x27,16,2); 
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
int i;


void setup()
{
  Serial.begin(9600);
vw_setup(2000);                 
vw_set_rx_pin(11);                
vw_rx_start(); 



 lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();  
lcd.setCursor (0,0);
lcd.print("  Car  parking  ");
lcd.setCursor (0,1);
lcd.print("    System     ");
delay (2000);
lcd.clear();  
lcd.setCursor (0,0);
lcd.print(" Have Slot: "); 
lcd.print(4);
lcd.print("    ");   
delay (2000);    
lcd.clear();               
}
void loop()
{

Serial.println("test_sent");

if (vw_get_message(buf, &buflen))
{
 
lcd.setCursor(0,0);
if(strcmp("Empty1", (char*)buf) == 0)
{lcd.print("S1:Empty");
Serial.println("S1:0");  
                              }
else{
lcd.print("S1:Fill");
Serial.println("S1:1");
                                  }


lcd.setCursor(8,0);
if(strcmp("Empty2", (char*)buf) == 0)
{lcd.print("S2:Empty");
Serial.println("S2:0"); 
                           }
else{
lcd.print("S2:Fill");
Serial.println("S2:1");
                           }
lcd.setCursor(0,1);
if(strcmp("Empty3", (char*)buf) == 0)
{lcd.print("S3:Empty");
Serial.println("S3:0"); 
                           }
else{
lcd.print("S3:Fill");
Serial.println("S3:1");
                           }

lcd.setCursor(8,1);
if(strcmp("Empty4", (char*)buf) == 0)
{lcd.print("S4:Empty");
Serial.println("S4:0"); 
                           }
else{
lcd.print("S4:Fill");
Serial.println("S4:1");
                           }
                           
for (i = 0; i < buflen; i++)
         { 
           lcd.write(buf[i]); 
                    
         }
        
                              
}

delay(1000);
}

What's going on? Serial print works but LCD print doesn't work?

This is the problem, do you have a solution?

But... the photograph shows the LCD working! ...

Does the LCD show anything? Does the LCD show a row of squares on one or two lines? Does the LCD show characters, just not the right characters?