// LIFI communication
//CB.EN.U4ECE23206- A.SRI CHARAN
//controlling LED state by transmitting light signal
//if Illumination of LDR increases above thresh-hold, second LED glows
//Illumination on ldr sensor controlled by first LED
// Define the pin number for the LED
#define LED_PIN 3
// Define the pin number for the Light Dependent Resistor (LDR)
#define LDR_PIN A2
// Define the threshold value for the LDR
#define THRESHOLD 200
void setup() {
// Set the LED pin as an output pin
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Read the LDR value and set the LED state accordingly
digitalWrite(LED_PIN, getldr());
}
// Function to read the LDR value and determine LED state
bool getldr() {
// Read the analog value from the LDR pin
int voltage = analogRead(LDR_PIN);
// Check if the analog value exceeds the threshold
// and return true if it does, otherwise return false
return voltage > THRESHOLD ? true : false;
}