TL;DR ver:
LED light controlled with Arduino lights up during an interval of 2 frames, not one in a video footage of 30 FPS. It slowly turns on... but why?
=====
I have a (mouse) behavioral experiment set up with an Arduino Mega board (ATMega2560 chip), which is programmed to control an LED to turn on and off repeatedly (blink) with 1 second intervals. The Arduino code is very simple with DigitalWrites and time controls. LED is a commonly seen 3pi 567nm yellowgreen one.
Also, the board is programmed to send GPIO pulse signals every time it DigitalWrites to the LED. The video is taken with Logitech C922 webcam (30 FPS, 720p) and the whole point of blinking LED is to sync the video footage with a cell recording done simultaneously.
However, after examining the video footage, It just seemed to me that the LED signal was not 'crisp' enough. The LED brightness visually peaked during an interval of 2 frames, not one. It almost took 1/15 of seconds which was much longer than I expected.
GPIO signals were crisp with less than 1 millisecond of delay and seemed to reflect DigitalWrite.
So... after surfing the internet for any clues, I found out that direct emission diodes had a turn-on time of single digit or at most tens of 'nano'seconds, which was not what I was seeing in the video footage.
Some LEDs with junction capacitance or parasitic(?) capacitance seem to lengthen the RC time leading to slower switching. (https://lednique.com/led-speed/)
Also, there seemed to be a technical delay regarding DigitalWrite function over direct board writing in Arduino, but the magnitude of the delay seemed negligible to this case.
regular digitalWrite() in Arduino Uno core (16MHz) takes about 6.28 µs while digitalWriteFast() port manipulation takes 125 ns (https://github.com/NicksonYap/digitalWriteFast)
I have no background in electrical engineering, and I was wondering if this can be explained. My hypothesis is either
- It is a faulty diode with big junction capacitance.
- Sudden change in brightness cannot be recorded in a low-end video capturing device (such as Logitech webcam C922) and nanosecond change in brightness is recorded in the footage with delays.
Swapping the LED with the same type (only have one type atm) did not change the slow turn-on.
I am not aware of real-world data and whether faulty LEDs can actually turn on that slowly (over 1/15 second), so I'm asking for advice.
Any advices are welcome. I will try to additionally upload specific details if needed.
Thanks in advance :D