Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LiFi Communication System Using Arduino

1. Introduction

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.


2. Principle

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.


3. Components Used

  • Arduino UNO
  • LED
  • LDR
  • Resistors
  • Breadboard
  • Jumper wires

4. Procedure

  1. Connect the Arduino UNO to the computer using a USB cable.
  2. Connect the LED to digital pin 13 through a resistor and connect its other end to GND.
  3. Connect the LDR in a voltage divider circuit and connect its output to analog pin A0.
  4. Open Arduino IDE β†’ Select Tools β†’ Board β†’ Arduino UNO.
  5. Select the correct port from Tools β†’ Port.
  6. Upload the LiFi code to the Arduino.
  7. Open Serial Monitor (top-right icon) and set baud rate to 9600.
  8. Enter a message and press Enter.
  9. Observe LED transmission and received output in Serial Monitor.

5. Code (C++)

#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);
  }
}

Output

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.ino in the root directory of this repository β€” open it directly in Arduino IDE.


6. Experimental Setup

LED acts as a transmitter, and LDR acts as a receiver.


7. Advantages

  • High speed and secure communication
  • No electromagnetic interference
  • Energy efficient

8. Disadvantages

  • Requires line-of-sight
  • Affected by external light
  • Limited range

9. Result

The transmitted message was successfully received and displayed in the Serial Monitor.


10. Conclusion

This project demonstrates how light can be used for data transmission and shows the practical implementation of LiFi using Arduino.


πŸš€ Deploy to GitHub Pages

Step 1 β€” Create a new repository

Go to github.com/new and create a repository named lifi (public).

Step 2 β€” Upload the files

Upload all files to the root of your repository:

  • index.html
  • style.css
  • script.js
  • lifi.ino
  • README.md

Step 3 β€” Enable GitHub Pages

  1. Go to your repository β†’ Settings β†’ Pages
  2. Under Source, select main branch and / (root) folder
  3. Click Save

Your site will be live at: https://gssriram9050.github.io/lifi/


Made by Sriram G S Β Β·Β  LiFi Communication System Using Arduino Β Β·Β  Β© 2026

About

πŸ’‘ LiFi Communication System β€” A working optical wireless communication demo transmitting text via LED light pulses, decoded by an LDR sensor and reconstructed through the Arduino Serial Monitor. Built with C++ & Arduino UNO. [23SPH124 Physics for Computing Engineers Mini Project]

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages