Introduction: Arduino DSLR Lightning Catcher

I always wanted to shoot some lightnings but never knew how.

So I set down and made this Arduino DSLR Lightning Catcher.
The idea is to constantly mesure the ambient light and when sensing a spike in the light taking a shoot.

Step 1: The Need List

A DSLR camera
An Arduino board
2 X 220ohm resistor
A small PL conector (like the headphone only a bit smaller)
1 X 3-cord cable
1 Optoisolator
1 Potentiometer
A Led (optional)
1 Photocell

* Notice that in the diagram i forgot to put a resistor from the photocell to ground, do it as written below.

Step 2: Making the Cord

The PL connector connect to the camera's remote jack, the other side of the cable goes to the bread board.
To make a shoot you need to short two of the cables comming from the camera :
Automatic Camera Shutter Switch by DIY Hacks and How Tos

Step 3: Conacting the Potentiometer

The potentiometer is there to set the level of senstivity for light spikes.
Connect the left pin to ground, connect right pin to 5v, connect mid pin to Analog 5 (A5) on the arduino

Step 4: Photo Cell

The photocell is the part sensing the light, so when finaly setting the scene for shooting it is best to point it to the view as seen from the lens.

Connect one pin to Analog 0 (A0) on the arduino and also to a 220ohm resistor (pull down) and to the ground.
Connect second pin to 5v

Step 5: OptoIsolator

The Optoisolator is like a Realy, switching a circuit on while reciving power from another circuit only it is
made with IR led and IR reciver resistor so like the relay the two circuits never connect only faster then electromagnets.

Connect the Base to Arduino's pin 10 and the Emitter through a 220ohm resistor to GND.
Connect the Anode to the Camera's GND and the Cathode to Camera Shutter.

Step 6: The Code

So, as I written earlier, the code is constanly mesuring the light levels and calculating its avrage calling it ambient,
But when sensing a sodden spike in the mesuring takes a shoot

// Lightning Catcher for Arduino <br>// Written by Uria Dubinsky
// www.udpic.co.il
#define poten A5                    // Potentiometer Analog pin no. 5, for setting sensetivity
#define seLight A0              // Light Sensor Analog pin no. 0
#define shoot 10                    // Optisolator Digital pin no. 10 for making the shoot
int ambient =0;                    // integer for the ambient light avrage keeping
int sensitiv, lastSens;      // sensitiv integer for keeping the sensetivity levels value, lastSens integer for keeping the last light metring value
void setup () {
  Serial.begin (9600);
  pinMode (poten, INPUT);              // Setting the pins modes
  pinMode (seLight, INPUT);
  pinMode (shoot, OUTPUT);
  
  digitalWrite (shoot, LOW);      // Making sure the shoot pin is LOW
  ambient = analogRead (seLight);        // insert a first ambient value
}
void loop () {
    lastSens = analogRead (seLight);        // Analog reading the light sensor
    if (isSpike (lastSens) == false) {        // Compering the ambient value for a spike in the light (through the isSpike function)
      ambient = ((ambient + lastSens) / 2);    // If there is no spike enters the value to the ambient avrage
    }
    else {
        digitalWrite (shoot, HIGH);                  // If there is a spike in the light making the shoot
        delay (20);
        digitalWrite (shoot, LOW);
    }
}
boolean isSpike (int sensRead) {              // Function recive the value of the last light mesuring and return true for a spike and false for non
  sensitiv = analogRead (poten);
  if (sensRead <= ambient+sensitiv ) return false; else return true;
}