Visible light communication
Build it step by step
0 of 6 doneBuild the transmitter
Wire the MOSFET, resistors and white LED and upload the sender sketch.
Check the flicker
The LED looks steady to the eye; a phone camera in slow motion may show banding.
Build the receiver
Wire the photodiode, comparator and pull-up.
Set the threshold
Point the LED at the photodiode and adjust the pot until the receiver pin toggles with the data.
Upload the receiver
Open the Serial Monitor at 115200 and read the text.
Find the limit
Raise the baud rate on both ends until errors appear.
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
- Development BoardsBuyArduino Nano × 2
- OptoelectronicsBuyLED 5 mm white × 1
- SemiconductorsBuyMOSFET IRLZ44N × 1
- SensorsBuyPhotodiode BPW34 × 1
- Integrated CircuitsBuyLM393 Comparator × 1
- PassivesBuyResistor 10 kΩ × 3
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuyResistor 220 Ω × 1
- PassivesBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Sender Nano D3 | 1 kΩ resistor then MOSFET gate | Serial data out |
| 10 kΩ resistor | MOSFET gate and GND | Keeps the LED off at start-up |
| MOSFET source | Sender GND | Ground |
| Sender 5V | 220 Ω resistor then white LED anode | LED supply |
| White LED cathode | MOSFET drain | The LED is on while the data line is high |
| Photodiode BPW34 cathode | Receiver 5V | Reverse biased |
| Photodiode BPW34 anode | 10 kΩ resistor to GND and LM393 pin 3 (IN+) | Photocurrent becomes voltage |
| 10 kΩ potentiometer outer pins | Receiver 5V and GND | Threshold control |
| Potentiometer wiper | LM393 pin 2 (IN-) | Switching level |
| LM393 pin 8, pin 4 | Receiver 5V, GND | Power |
| 10 kΩ resistor | LM393 pin 1 (OUT) and 5V | Pull-up for the open-collector output |
| LM393 pin 1 (OUT) | Receiver Nano D2 | Serial data in |
| Sender GND and receiver GND | Joined, or both from the same USB hub | Common 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.
| Check | Expected |
|---|---|
| LED facing the photodiode | Message appears on the receiver |
| LED covered | Nothing received |
| Room light switched on | May need a new threshold |
| Distance increased | Errors 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 →
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.
