I'm looking to build an Arduino-based "camera flash logger" to detect when a camera flash goes off, and maintain a log of those events. My thinking is to use a photoresistor to measure light level, and watch for sudden changes using a loop. Something like:
const int ldrPin = A0;
// no idea what this number would end up being
// just putting something here to start with
const int threshold = 10;
int currentLevel, lastLevel = 0;
void setup() {
Serial.begin(9600);
pinMode(ldrPin, INPUT);
}
void loop() {
lastLevel = currentLevel;
currentLevel = analogRead( ldrPin );
// look for a sudden change
if( abs( lastLevel - currentLevel ) > threshold ) {
// serial out here to simplify the example.
// I'll be logging outputs (with timestamps) to an SD card.
Serial.println( currentLevel );
}
}
A couple of things I'm not sure of though:
will the response time of a photoresistor be fast enough to respond to the very short (sometimes less than 1ms) burst from a camera flash?
is a loop measuring level changes the best way to go about this, or would something like a state change interrupt be better? The ambient light level will vary depending on time of day, so it's an edge detection problem, as opposed to just reading a light level.
Apologies if this comes across as a "you haven't done your homework yet" question. I haven't started the project yet, so all I'm hoping for is a little direction on which way to proceed.