Understand how a photodiode converts light into current and voltage.
Use Arduino to measure ambient light, darkness, and LED flicker.
Deploy Red Pitaya STEMlab 125-14 to visualize high-speed light fluctuations
Theory & Introduction
Modern sensing systems often need to monitor not only slow changesâlike a day/night cycleâbut also fast fluctuations, such as flicker in lighting. Flicker can arise from AC mains, poorly regulated LED drivers, or purposeful modulation (e.g. IR remote signals). A photodiode is an ideal sensor for this task: under illumination it produces a current proportional to light intensity, which we can convert to a voltage and digitize with a microcontroller.
Photodiode Basics
Structure:
A photodiode is a pân junction operated in reverse bias (or zero bias) so that incoming photons generate electronâhole pairs, resulting in a photocurrent.
Linear Response: Iphâ=RĂP
Within its operating range, photocurrent Iph is approximately proportional to incident light power P, where R (A/W) is the responsiveness of the device.
Quantify ambient and dark conditions with Arduinoâs ADC.
Drive LEDs at controlled flicker rates and observe the photodiodeâs analog readings.
Visualize the same flicker in fine detail on the Red Pitayaâcapturing fast edges, envelope shape, and spectral content.
By comparing Arduinoâs coarse readings to Red Pitayaâs high-speed plots, youâll learn both the capabilities and limitations of embedded ADCsâand see why high-speed instruments are indispensable for characterizing transient phenomena like light flicker.
// Part A: Ambient vs. Dark
const int photoPin = A0;
void setup() {
Serial.begin(115200);
}
void loop() {
int v = analogRead(photoPin); // 0â1023
Serial.println(v);
delay(200); // 200 ms between readings
}
Upload the sketch.
OpenTools â Serial Plotter.
Ambient: point photodiode at room light â ~600â800.
Dark: cover photodiode â near 0.
*note that some photodiodes might produce inverted result.
// Part B: Steady LED
const int photoPin = A0;
const int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(ledPin, HIGH); // LEDâ ON
Serial.println(analogRead(photoPin));
delay(200);
}
Observation & Explanation
When LEDâ turns ON, the photodiode sees maximum light, reading ~1023.
Plot: a flat high lineâconfirms full-scale photodiode response.
C. Single-LED 100 Hz Flicker
Wiring (no change)
LEDâ on D9 + photodiode as before.
Code: 100 Hz Blink
// Part C: Manual 100 Hz Flicker
const int photoPin = A0;
const int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(ledPin, HIGH);
delayMicroseconds(5000); // 5 ms ON @100 Hz
Serial.println(analogRead(photoPin));
digitalWrite(ledPin, LOW);
delayMicroseconds(5000); // 5 ms OFF
Serial.println(analogRead(photoPin));
Serial.println("---"); // cycle marker
}
Upload the code.
Observe the signal using the red pitaya oscilloscope. The signal captured on the photodiode resembles the square signal (on/off) we are powering the LED with.
Adjust the 5000 value to explore other frequencies.
D. Dual-LED Flicker & Photodiode Response
In this section, we drive two LEDs at different blink rates and observe how the photodiode âseesâ their combined light on the Red Pitaya oscilloscope.
The photodiode sees the superposition of both flickers.
Red Pitaya Oscilloscope
Run the dual-blink sketch.
Open Oscilloscope on Red Pitaya.
Set oscilloscope that you see at least 2 periods.
*differences in 50% signal combinations come from setting up your LEDs unequally in respect to the photodiode.
Connecting Results
Envelope (50 Hz): The taller peaks correspond to LEDâ on-cycles.
Sub-peaks (100 Hz): Within each 20 ms window, LEDâ adds a faster modulation.
Photodiode Output: Shows how two light sources at different frequencies combine into a single analog signal.
By comparing the captured waveform to our code, students can visually confirm superposition of flicker rates and appreciate how the photodiode plus Red Pitaya reveal complex light patternsâinsights that simple Arduino sampling alone cannot capture cleanly.
Conclusion
This experiment demonstrated how photodiodes can be used to detect both slow and fast changes in light intensity, and how different toolsâArduino and Red Pitayaâoffer complementary insights into signal behavior.
Using the Arduino, we measured ambient light and LED flicker with basic analog readings, suitable for slow or steady signals. However, when analyzing high-frequency flicker (e.g., 100 Hz or dual-LED modulation), the Arduinoâs limited sampling rate proved insufficient to capture fine details.
By contrast, the Red Pitaya STEMlab 125-14 provided high-resolution waveform and spectral analysis, revealing the true shape and frequency content of the flicker signals. This allowed us to visualize how multiple light sources interact and how flicker manifests in real-world lighting systems.
The experiment highlighted:
The linear response of photodiodes to light intensity.
The importance of pull-up resistors for voltage conversion.
The limitations of low-speed ADCs in capturing transient phenomena.
The value of high-speed tools like Red Pitaya in diagnosing flicker and validating signal integrity.
Overall, this lab provided a practical understanding of light sensing, signal acquisition, and the trade-offs between embedded and high-performance measurement systemsâskills essential for designing reliable optical and electronic systems.