Projects / Visible light communication

Visible light communication

Intermediate2.5 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANOIRLZ448.9 mA

    Build the transmitter

    Wire the MOSFET, resistors and white LED and upload the sender sketch.

  2. NANO8.9 mA

    Check the flicker

    The LED looks steady to the eye; a phone camera in slow motion may show banding.

  3. NANOLM393

    Build the receiver

    Wire the photodiode, comparator and pull-up.

  4. NANO8.9 mA

    Set the threshold

    Point the LED at the photodiode and adjust the pot until the receiver pin toggles with the data.

  5. NANO

    Upload the receiver

    Open the Serial Monitor at 115200 and read the text.

  6. NANO

    Find the limit

    Raise the baud rate on both ends until errors appear.

In short

How do you build a visible light communication?

An LED flickers too fast to see and a photodiode receives text, like a simple Li-Fi link. You need Arduino Nano × 2, LED 5 mm white, MOSFET IRLZ44N, Photodiode BPW34, LM393 Comparator, Resistor 10 kΩ × 3, Resistor 1 kΩ, Resistor 220 Ω, Potentiometer 10 kΩ and Breadboard 830 Tie Points × 2. It takes 6 steps and about 150 minutes.

Level
Intermediate
Time
About 150 min
Parts
10

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Sender Nano D31 kΩ resistor then MOSFET gateSerial data out
10 kΩ resistorMOSFET gate and GNDKeeps the LED off at start-up
MOSFET sourceSender GNDGround
Sender 5V220 Ω resistor then white LED anodeLED supply
White LED cathodeMOSFET drainThe LED is on while the data line is high
Photodiode BPW34 cathodeReceiver 5VReverse biased
Photodiode BPW34 anode10 kΩ resistor to GND and LM393 pin 3 (IN+)Photocurrent becomes voltage
10 kΩ potentiometer outer pinsReceiver 5V and GNDThreshold control
Potentiometer wiperLM393 pin 2 (IN-)Switching level
LM393 pin 8, pin 4Receiver 5V, GNDPower
10 kΩ resistorLM393 pin 1 (OUT) and 5VPull-up for the open-collector output
LM393 pin 1 (OUT)Receiver Nano D2Serial data in
Sender GND and receiver GNDJoined, or both from the same USB hubCommon ground

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries needed beyond the built-in SoftwareSerial. The serial line idles high, so the LED is on at rest and flickers during data. A BPW34 is a photodiode with a large area; it sits reverse-biased with its cathode to 5 V. Test in a dim room at first: bright ambient light lifts the photodiode node, so set the threshold pot to sit between the LED-on and LED-off levels. Keep the LED and photodiode a few centimetres apart facing each other. Try raising the baud rate in steps of 9600 to find the top speed.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// ---- Sender sketch (Nano 1): sends text with a software serial port through the LED ----
#include <SoftwareSerial.h>
SoftwareSerial tx(10, 3);          // RX (unused), TX on D3
void setup() { tx.begin(9600); }
void loop() {
  tx.println("HELLO FROM THE LIGHT");
  delay(2000);
}

/* ---- Receiver sketch (Nano 2) ----
#include <SoftwareSerial.h>
SoftwareSerial rx(2, 11);          // RX on D2, TX unused
void setup() { Serial.begin(115200); rx.begin(9600); }
void loop() {
  while (rx.available()) Serial.write(rx.read());
}
*/

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
LED facing the photodiodeMessage appears on the receiver
LED coveredNothing received
Room light switched onMay need a new threshold
Distance increasedErrors appear beyond a few tens of centimetres

If it does not work

Nothing received

Check the photodiode orientation and the comparator output with a meter.

Garbled text

Threshold is off or the baud rates differ. Retune and match them.

LED never flickers

Check the MOSFET gate wire and the sender pin.

Works only when very close

Add a lens or tube around the photodiode to shut out ambient light.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the visible light communication?

Arduino Nano × 2, LED 5 mm white, MOSFET IRLZ44N, Photodiode BPW34, LM393 Comparator, Resistor 10 kΩ × 3, Resistor 1 kΩ, Resistor 220 Ω, Potentiometer 10 kΩ and Breadboard 830 Tie Points × 2.

How long does the visible light communication take to build?

About 150 minutes for a intermediate maker, in 6 steps.

How do I know the visible light communication works?

LED facing the photodiode: Message appears on the receiver. LED covered: Nothing received. Room light switched on: May need a new threshold.

Nothing received: what should I check?

Check the photodiode orientation and the comparator output with a meter.

Garbled text: what should I check?

Threshold is off or the baud rates differ. Retune and match them.

LED never flickers: what should I check?

Check the MOSFET gate wire and the sender pin.

Works only when very close: what should I check?

Add a lens or tube around the photodiode to shut out ambient light.