Esp32 Not decoding Li-Fi

Hi forum,
I have an Esp32 That is receiving Data through Li-Fi then sends is to a webpage on my host using GET.

#define LDR_PIN 2
#define THRESHOLD 100
#define PERIOD 15



#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "tt";
const char* password =  "ttleboss";

void setup()
{
  Serial.begin(115200);
  pinMode(LDR_PIN, INPUT);

  WiFi.begin(ssid, password);
  Serial.println("Starting");
  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }
  Serial.println("Connected");
}

bool previous_state;
bool current_state = true ;

void loop()
{
  current_state = get_ldr();
  if (!current_state && previous_state)
  {
    print_byte(get_byte());
    Serial.println("testLDR1");
  }
  previous_state = current_state;
}

bool get_ldr()
{
  int voltage = analogRead(LDR_PIN);
  return voltage > THRESHOLD ? true : false;
}

char get_byte()
{
  char ret = 0;
  delay(PERIOD * 1.5);
  for (int i = 0; i < 8; i++)
  {
    ret = ret | get_ldr() << i;
    delay(PERIOD);
  }
  return ret;
}
void print_byte(char my_byte)
{
  char buff[2];
  sprintf(buff, "%c", my_byte);
  int value = atoi(buff);
  Serial.println(value);
  SendData(value);

}

void SendData(int val)
{
  Serial.println(String(val));
  Serial.println("test");
  if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status

    HTTPClient http;
    Serial.println(String(val));
    Serial.println("test1");

    http.begin("https://mysite.com/insert.php?Esp_Id=16&value1=" + String(val)); //Specify the URL
    int httpCode = http.GET();                                        //Make the request

    if (httpCode > 0) { //Check for the returning code

      String payload = http.getString();
      Serial.println(httpCode);
      Serial.println(payload);
    }

    else {
      Serial.println("Error on HTTP request");
    }

    http.end(); //Free the resources
  }

  delay(1000);

}

The program above exists of two separate programs that work on their own but together it doesn’t work at all.
I am using this project Wireless Data Transmission using LIGHT. DIY Li-Fi - Arduino Project Hub for the Li-Fi transmission.

#include <WiFi.h>
#include <HTTPClient.h>



const char* ssid = "xx";
const char* password =  "xx";

void setup() {

 Serial.begin(115200);
 delay(4000);
 WiFi.begin(ssid, password);

 while (WiFi.status() != WL_CONNECTED) {
   delay(1000);
   Serial.println("Connecting to WiFi..");
 }

 Serial.println("Connected to the WiFi network");

}

void loop() {

 if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status

   HTTPClient http;

   http.begin("https://mysite.com/insert.php?Esp_Id=16&value1=15"); //Specify the URL
   int httpCode = http.GET();                                        //Make the request

   if (httpCode > 0) { //Check for the returning code

       String payload = http.getString();
       Serial.println(httpCode);
       Serial.println(payload);
     }

   else {
     Serial.println("Error on HTTP request");
   }

   http.end(); //Free the resources
 }
 
 delay(1000);


}
#define LDR_PIN 2
#define THRESHOLD 100
#define PERIOD 15

bool previous_state;
bool current_state;

void setup() 
{
   Serial.begin(9600);
}

void loop() 
{
 current_state = get_ldr();
 if(!current_state && previous_state)
 {
   print_byte(get_byte());
 }
 previous_state = current_state;
}

bool get_ldr()
{
 int voltage = analogRead(LDR_PIN);
 return voltage > THRESHOLD ? true : false;
}

char get_byte()
{
 char ret = 0;
 delay(PERIOD*1.5);
 for(int i = 0; i < 8; i++)
 {
  ret = ret | get_ldr() << i; 
  delay(PERIOD);
 }
 return ret;
}
void print_byte(char my_byte)
{
 char buff[2];
 sprintf(buff, "%c", my_byte);
 Serial.print(buff);
}

Does anyone know why it won’t get past the loop in Project_Reciver?
My English isn’t the best I am sorry.

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here