Li-Fi based Text Communication between Two Arduino

I am trying to send text btw two Arduino board through lifi tech.
my transmitter side code is working fine, but in receiver side the ldr sensor n lcd display is not working please help me, and ldr is working fine, checked alredy here is my code

//Transmitter Side:
#include <Keypad.h>
const byte ROW = 4;
const byte COL = 4;
char keyscode[ROW][COL] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPin[ROW] = {A5, A4, A3, A2};
byte colPin[COL] = {A1, A0, 12, 11};
Keypad customKeypad = Keypad( makeKeymap(keyscode), rowPin, colPin, ROW, COL);
char keycount = 0;
char code[5];
void setup() 
{
  Serial.begin(9600);
  pinMode(8,OUTPUT);
  digitalWrite(8,LOW);
}
void loop()
{
  char customKey = customKeypad.getKey();
  if (customKey) {
    Serial.println(customKey);
   if (customKey == '1')
  {
    digitalWrite(8,HIGH);
    delay(10);
    digitalWrite(8,LOW);
  }
  else if (customKey == '2')
  {
    digitalWrite(8,HIGH);
    delay(20);
    digitalWrite(8,LOW);
  }
  else if (customKey == '3')
  {
    digitalWrite(8,HIGH);
    delay(30);
    digitalWrite(8,LOW);
  }
  else if (customKey == '4')
  {
    digitalWrite(8,HIGH);
    delay(40);
    digitalWrite(8,LOW);
  }
  else if (customKey == '5')
  {
    digitalWrite(8,HIGH);
    delay(50);
    digitalWrite(8,LOW);
  }
  else if (customKey == '6')
  {
    digitalWrite(8,HIGH);
    delay(60);
    digitalWrite(8,LOW);
  }
  else if (customKey == '7')
  {
    digitalWrite(8,HIGH);
    delay(70);
    digitalWrite(8,LOW);
  }
  else if (customKey == '8')
  {
    digitalWrite(8,HIGH);
    delay(80);
    digitalWrite(8,LOW);
  }
  else if (customKey == '9')
  {
    digitalWrite(8,HIGH);
    delay(90);
    digitalWrite(8,LOW);
  }
  else if (customKey == '*')
  {
    digitalWrite(8,HIGH);
    delay(100);
    digitalWrite(8,LOW);
  }
  else if (customKey == '0')
  {
    digitalWrite(8,HIGH);
    delay(110);
    digitalWrite(8,LOW);
  }
  else if (customKey == '#')
  {
    digitalWrite(8,HIGH);
    delay(120);
    digitalWrite(8,LOW);
  }
  else if (customKey == 'A')
  {
    digitalWrite(8,HIGH);
    delay(130);
    digitalWrite(8,LOW);
  }
  else if (customKey == 'B')
  {
    digitalWrite(8,HIGH);
    delay(140);
    digitalWrite(8,LOW);
  }
  else if (customKey == 'C')
  {
    digitalWrite(8,HIGH);
    delay(150);
    digitalWrite(8,LOW);
  }
  else if (customKey == 'D')
  {
    digitalWrite(8,HIGH);
    delay(160);
    digitalWrite(8,LOW);
  }
  else;
  } 
}
 
 
//Receiver Side:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <SoftwareSerial.h>
#include <Keypad.h>
void setup()
{
  pinMode(8, INPUT);
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  //lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("   WELCOME TO    ");
  lcd.setCursor(0, 1);
  lcd.print(" CIRCUIT DIGEST    ");
  delay(2000);
  lcd.clear();
}
void loop()
{
  unsigned long duration = pulseIn(8, HIGH);
  Serial.println(duration);
  if (duration > 10000 && duration < 17000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 1          ");
  }
  else if (duration > 20000 && duration < 27000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 2          ");
  }
  else if (duration > 30000 && duration < 37000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 3          ");
  }
  else if (duration > 40000 && duration < 47000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 4          ");
  }
  else if (duration > 50000 && duration < 57000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 5          ");
  }
  else if (duration > 60000 && duration < 67000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 6          ");
  }
  else if (duration > 70000 && duration < 77000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 7          ");
  }
  else if (duration > 80000 && duration < 87000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 8          ");
  }
  else if (duration > 90000 && duration < 97000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 9          ");
  }
  else if (duration > 100000 && duration < 107000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: *          ");
  }
  else if (duration > 110000 && duration < 117000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 0          ");
  }
  else if (duration > 120000 && duration < 127000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: #          ");
  }
  else if (duration > 130000 && duration < 137000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: A          ");
  }
  else if (duration > 140000 && duration < 147000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: B          ");
  }
  else if (duration > 150000 && duration < 157000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: C          ");
  }
  else if (duration > 160000 && duration < 167000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: D          ");
  }
}

i have uploaded the entire code that i have and the hardware connections

Your code is incomplete.

Please remember to use code tags when posting code.

as in?

As in "code tags".

Or did you mean "as in "the code you posted is incomplete, and so has not a hope in Hell of compiling, much less running" "?

incomplete
can you tell me where is the mistake?

transmitter side 

#include <LiquidCrystal_I2C.h>

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
//Assign key values in 4x4 matrix
char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
//connect to the row pinouts of the keypad
byte rowPins[ROWS] = {2, 3, 4, 5}; //R1,R2,R3,R4
//connect to the column pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9};//C1,C2,C3,C4

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

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}
void loop()
{
  char Key = keypad.getKey();
  if (Key) {
    Serial.println(Key);
    if (Key == '1')
    {
      digitalWrite(13, HIGH);
      delay(10);
      digitalWrite(13, LOW);
    }
    else if (Key == '2')
    {
      digitalWrite(13, HIGH);
      delay(20);
      digitalWrite(13, LOW);
    }
    else if (Key == '3')
    {
      digitalWrite(13, HIGH);
      delay(30);
      digitalWrite(13, LOW);
    }
    else if (Key == '4')
    {
      digitalWrite(13, HIGH);
      delay(40);
      digitalWrite(13, LOW);
    }
    else if (Key == '5')
    {
      digitalWrite(13, HIGH);
      delay(50);
      digitalWrite(13, LOW);
    }
    else if (Key == '6')
    {
      digitalWrite(13, HIGH);
      delay(60);
      digitalWrite(13, LOW);
    }
    else if (Key == '7')
    {
      digitalWrite(13, HIGH);
      delay(70);
      digitalWrite(13, LOW);
    }
    else if (Key == '8')
    {
      digitalWrite(13, HIGH);
      delay(80);
      digitalWrite(13, LOW);
    }
    else if (Key == '9')
    {
      digitalWrite(13, HIGH);
      delay(90);
      digitalWrite(13, LOW);
    }
    else if (Key == '*')
    {
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
    }
    else if (Key == '0')
    {
      digitalWrite(13, HIGH);
      delay(110);
      digitalWrite(13, LOW);
    }
    else if (Key == '#')
    {
      digitalWrite(13, HIGH);
      delay(120);
      digitalWrite(13, LOW);
    }
    else if (Key == 'A')
    {
      digitalWrite(13, HIGH);
      delay(130);
      digitalWrite(13, LOW);
    }
    else if (Key == 'B')
    {
      digitalWrite(13, HIGH);
      delay(140);
      digitalWrite(13, LOW);
    }
    else if (Key == 'C')
    {
      digitalWrite(13, HIGH);
      delay(150);
      digitalWrite(13, LOW);
    }
    else if (Key == 'D')
    {
      digitalWrite(13, HIGH);
      delay(160);
      digitalWrite(13, LOW);
    }
    else;
  }
}

receiver side

#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x3F, 16, 2); // Change to (0x27,20,4) for 20x4 LCD.
void setup() {
  // Initiate the LCD:
  lcd.init();
  lcd.backlight();

  // Print 'Hello World!' on the first line of the LCD:
  lcd.setCursor(2, 0); // Set the cursor on the third column and first row.
  lcd.print("Hello World!"); // Print the string "Hello World!"
  lcd.setCursor(2, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
  lcd.print("LCD tutorial");
  delay(2000);
  lcd.clear();
}
void loop()
{
  unsigned long duration = pulseIn(8, HIGH);
  Serial.println(duration);
  if (duration > 10000 && duration < 17000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 1          ");
  }
  else if (duration > 20000 && duration < 27000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 2          ");
  }
  else if (duration > 30000 && duration < 37000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 3          ");
  }
  else if (duration > 40000 && duration < 47000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 4          ");
  }
  else if (duration > 50000 && duration < 57000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 5          ");
  }
  else if (duration > 60000 && duration < 67000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 6          ");
  }
  else if (duration > 70000 && duration < 77000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 7          ");
  }
  else if (duration > 80000 && duration < 87000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 8          ");
  }
  else if (duration > 90000 && duration < 97000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 9          ");
  }
  else if (duration > 100000 && duration < 107000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: *          ");
  }
  else if (duration > 110000 && duration < 117000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: 0          ");
  }
  else if (duration > 120000 && duration < 127000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: #          ");
  }
  else if (duration > 130000 && duration < 137000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: A          ");
  }
  else if (duration > 140000 && duration < 147000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: B          ");
  }
  else if (duration > 150000 && duration < 157000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: C          ");
  }
  else if (duration > 160000 && duration < 167000)
  {
    lcd.setCursor(0, 0);
    lcd.print("Received: D          ");
  }
}

The mistake could be in the code you didn't post.

this is the entire code

Hello @rach24
It would help you to get help if you read this before continuing:

As @TheMemberFormerlyKnownAsAWOL says, your code is not complete. I don't think we need to point out exactly where because you can find out by comparing what you posted with what you actually have.

Also, your title won't attract people who might be able to help, use a more meaningful title.
We need a lot more as per the instructions, such as what hardware you have and some idea of how it's wired, and some photos, at the very least. The instructions tell you all this, you should read them then come back.

Thank you.

@rach24
I have deleted your other topic on the same subject. If you bother to read the instructions you will know that posting the same question more than once is against the forum rules because it wastes people's time. You can edit THIS question to give it a meaningful title and to apply code tags.

Thank you.

Thank you for patiently telling me , i have edited as advised

1 Like

Please edit your post #6 to fix the code tags. Also, in the Arduino IDE, press CTRL-T before copy/paste, to indent the code correctly. Makes it easier to read!

please check now, and advise me on the same

1 Like

The receiver side compiles correctly, but you forgot to mention what the problem is. What do you expect to happen and what happens instead?

BTW, LDRs are very slow to respond, and are usually not appropriate for capturing timed signals. Please describe how it is wired to the Arduino.

i am not getting the output on the lcd screen,
only the hello world is reflected, but the key pad entries are not read, ldr is in series with 10km ohm resistor, one end of ldr is connected to Arduino pin 8 n resistor is connected to the ground

What values does this line print out?

Serial.println(duration);`

the serial monitor is not giving any output either

Sounds like the pin is connected through the LDR and 10k resistor to Ground. It will always read 0. Typically the LDR would be between the pin and +5V while the load resistor would be between the pin and Ground.

I made circuit changes as you told but getting the same value 0

It sounds like there are no recognizable pulses on the input. You can read about how to use pulseIn() here:

https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/

Consider using the timeout option, and post a wiring diagram of your setup. Hand drawn is fine.