LiFi (Light Fidelity) is a wireless communication technology that uses visible light to transmit data. Unlike WiFi, which uses radio waves, LiFi uses LED light for communication. It enables fast, secure, and interference-free data transmission.
LiFi works on light modulation. The LED transmits data by switching ON and OFF rapidly to represent binary values (1 and 0). An LDR detects these light changes and converts them into electrical signals, which are processed by the Arduino to reconstruct the data.
- Arduino UNO
- LED
- LDR
- Resistors
- Breadboard
- Jumper wires
- Connect the Arduino UNO to the computer using a USB cable.
- Connect the LED to digital pin 13 through a resistor and connect its other end to GND.
- Connect the LDR in a voltage divider circuit and connect its output to analog pin A0.
- Open Arduino IDE β Select Tools β Board β Arduino UNO.
- Select the correct port from Tools β Port.
- Upload the LiFi code to the Arduino.
- Open Serial Monitor (top-right icon) and set baud rate to 9600.
- Enter a message and press Enter.
- Observe LED transmission and received output in Serial Monitor.
#define LED_PIN 13
#define LDR_PIN A0
int threshold = 400;
int readStableBit() {
int sum = 0;
for (int i = 0; i < 3; i++) {
sum += analogRead(LDR_PIN);
delay(5);
}
int avg = sum / 3;
return (avg < threshold) ? 1 : 0;
}
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
String input = Serial.readString();
input.trim();
String received = "";
for (int i = 0; i < input.length(); i++) {
char ch = input[i];
char out = 0;
for (int b = 0; b < 8; b++) {
int bit = (ch >> b) & 1;
digitalWrite(LED_PIN, bit);
delay(120);
int r = readStableBit();
out |= (r << b);
delay(200);
}
received += out;
}
Serial.print("Output: ");
Serial.println(received);
}
}LiFi System Ready
Enter message:
--- Transmission Start ---
Input: kce
Character: k
Sent: 1 | Received: 1
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Sent: 1 | Received: 1
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Character: c
Sent: 1 | Received: 1
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Sent: 0 | Received: 0
Sent: 0 | Received: 0
Sent: 1 | Received: 1
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Character: e
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Sent: 1 | Received: 1
Sent: 0 | Received: 0
Sent: 0 | Received: 0
Sent: 1 | Received: 1
Sent: 1 | Received: 1
Sent: 0 | Received: 0
--- Transmission End ---
Output: kce
------------------------
π The complete sketch is also available as
lifi.inoin the root directory of this repository β open it directly in Arduino IDE.
LED acts as a transmitter, and LDR acts as a receiver.
- High speed and secure communication
- No electromagnetic interference
- Energy efficient
- Requires line-of-sight
- Affected by external light
- Limited range
The transmitted message was successfully received and displayed in the Serial Monitor.
This project demonstrates how light can be used for data transmission and shows the practical implementation of LiFi using Arduino.
Go to github.com/new and create a repository named lifi (public).
Upload all files to the root of your repository:
index.htmlstyle.cssscript.jslifi.inoREADME.md
- Go to your repository β Settings β Pages
- Under Source, select
mainbranch and/ (root)folder - Click Save
Your site will be live at:
https://gssriram9050.github.io/lifi/
Made by Sriram G S Β Β·Β LiFi Communication System Using Arduino Β Β·Β Β© 2026