Send Text using LiFi Technology

Currently i am working on project to send data using LiFi , I want to Send data(string) by converting it into binary using LED on one arduino and recieve data on the other arduino using LDR ,Can anyone please help me with the code of the recieving Side. i am able to get 1 value by using the attachced code ... but when i set and else condition in this code the arduino is stucked in a loop .... iF you have any other working code for the same please send it to me ASAP ...it will be a great help Thank you
unsigned long StartTime = millis();

unsigned long Value;
unsigned long EndTime;

int Message;
int flag=0;
boolean StartedCounting = false; //this is used to determine if the counting has started

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

void loop() {

int sensorValue = analogRead(A0); //read the sensor value

delay(1); // to stabilize

// Serial.println(sensorValue); // this can be used to determine the threshold in your lighting conditions

flag=0;

if (sensorValue>825)
{

Serial.println("1");
flag=1;
}
else{
//Serial.print("0");// I have commented this code because it causes the infinite loop

} }

Recieve_Data.ino (753 Bytes)