Firstly - I'm a newbie to arduino and my programming skills are 20 years rusty (was trained in dBIV )
After a few weeks of reading & playing with my UNO I need some help. My first proper project is a camera shutter but because I'm doing it a little different I decided to try & time the delay - ideally I want to capture lightning.
I know this isnt the normal way to do it but here goes - I'm using a solar cell as the light detector, a pot to set the sensitivity and have an optical isolator between the arduino and the camera trigger.
The camera is prefocused and the focus line is grounded so I am only switching the shutter button.
It's working, but the delay is a little longer than I want - Testing with flicking a lighter or even firing a slave flash 20 metres away works, but the corresponding photo shows no sign of the trigger light itself. So I naturally decided to try & time it.
I have a 1638 that is counting after the trigger level is met. The photos of the counter are showing (it think) 26ms with a shutter speed of 1/125 but what it isnt showing is the delay in the detector... which is what I want to know about too.
And a longer shutter (1/50) is showing the 26/27 delay.
What I want to do, is have the arduino fire the trigger led on the detector, start the timer and then send the camera trigger but every attempt I have made so far the timer stops when the fire signal is sent.
Thanks in advance for any help, and please understand 2 things, this is about the limit of what I have learnt after a couple of weeks bashing about and also - most of my electronics are scavenged form old printers etc as I'm a reasonable distance from any shop I could get a 220 ohm resistor from and I enjoy tearing down hardware with my children.
Code below, I have brutally removed some comments I've left myself and normally I wouldnt be outputting to the 1638..
#include <TM1638.h>
int led = 13;
int trigger = 2;
int potPin = A0;
int lightValue = 0;
int sensorValue = 0;
TM1638 module(8, 9, 7);
unsigned long a=1;
void setup() {
pinMode(led, OUTPUT);
pinMode(trigger, OUTPUT);
}
void loop() {
int sensorValue = analogRead(potPin);
int lightValue = analogRead(A1);
if (lightValue > sensorValue){
digitalWrite(led, HIGH);
digitalWrite(trigger, HIGH);
for (a=1; a<1000; a++)
{
module.setDisplayToDecNumber(a,4,false);
delay(1);
}
digitalWrite(led, LOW);
digitalWrite(trigger, LOW);
}
}