Introduction: ARDUINO Photogate for HIGH SPEED Photography

Over the last few weeks I have been searching the internet for high speed photograph using a ARDUINO, So far over 90% of the projects I found used sound as the trigger. If you are trying to get a picture of a balloon popping that would work fine. But what I was after was pictures of water splashes and glass breaking as it hit the floor.
I finally gave up searching and decided to come up with my own design that triggered when motion was detected, What I came up with was a larger home made version of a photogate (also called a photo interrupter).
The following instructable will show you how to make and use a ARDUINO photogate for HIGH SPEED photography..

Step 1: Building the Photogate.

For the full directions to build this and a demonstration of it working check out the Youtube video I made for this at this link:

https://youtu.be/6WIr-ZWxDLA

Step 2: Circuit and Code

You will need to download and install the following library's:

IRremote.

LCD_I2C.

// THE CODE //


#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

#include <IRremote.h>
#define RECV_PIN 4
IRrecv irrecv(RECV_PIN);
decode_results remote;
#define irLed 12 //ir led on pin 12
int button = 0; //ir button tracker
int fdel = 0; //flash trigger delay
int pdel = 0; //last flash trigger delay
int camb = 10000; //camera bulb time
int pcamb = 10000; //last camera bulb time
#define camt 10 //camera trigger pin
#define flash 8 //flash trigger pin
int b = 0;
int x = 0; //while loop hold
int y = 0; //while loop counter
int z = 0; //push button while loop
int irt; //ir transistor value
int pirt; //last ir transistor value
int irTrigger = 900; // flash trigger threshold
int pirTrigger = 900; //last flash trigger threshold
#define pButton 7 //push button on pin 7
#define lcdLight 6 //lcd back light on off pin 6
#define relay 9
void setup() {
// Serial.begin(9600); // for testing
lcd.begin(16, 2); // initialize the lcd for 16 chars 2 lines
lcd.clear();
irrecv.enableIRIn(); // Start the receiver
pinMode(irLed, OUTPUT);
pinMode(camt, OUTPUT);
pinMode(flash, OUTPUT);
pinMode(pButton, INPUT_PULLUP);
digitalWrite(irLed, HIGH);
pinMode(lcdLight,OUTPUT);
digitalWrite(lcdLight,HIGH);
pinMode(relay,OUTPUT);
}
void loop()
{
// irt=analogRead(A0); //ir transistor value 4 testing
// Serial.println(irt);
digitalWrite(lcdLight,HIGH);
//// keep lcd display correct////
fdel = constrain(fdel, 0, 999);
if (fdel == 9 && pdel == 10 || fdel == 99 && pdel == 100)
{
lcd.clear();
}
pdel = fdel;
camb = constrain(camb, 3000, 30000); //3-30 sec bulb time
if (camb == 9500 && pcamb == 10000)
{
lcd.clear();
}
pcamb = camb;
irTrigger = constrain(irTrigger, 100, 1022);
if (irTrigger == 999 && pirTrigger == 1000)
{
lcd.clear();
}
pirTrigger = irTrigger;
//////////LCD data//////////
lcd.setCursor(0, 0);
lcd.print("DEL:");
lcd.setCursor(4, 0);
lcd.print(fdel);
lcd.setCursor(8, 0);
lcd.print("IRT:");
lcd.setCursor(12, 0);
lcd.print(irTrigger);
lcd.setCursor(0, 1);
lcd.print("BULB TIMER:");
lcd.setCursor(11, 1);
lcd.print(camb);
//////////check for ir input//////////
if (irrecv.decode(&remote)) {
//Serial.println(remote.value); //////////this is for mapping your remote//////////

//////camera triger stage//////
if (remote.value == 1320368837)
{
lcd.clear();
digitalWrite(lcdLight,LOW); //turn lcd off
digitalWrite(relay,HIGH);
delay(1000);
digitalWrite(camt, HIGH); //open camera shutter
x = 1;
while (x == 1) // hold for ir threshold to be triggered
{
y = y + 1;
delay(1);
irt = analogRead(A0); //read ir transistor
// Serial.println(irt); //for testing
if (irt < irTrigger) // triger the flash
{
delay(fdel);
digitalWrite(flash, HIGH);
delay(20);
digitalWrite(flash, LOW);
x = 0;
y = 0;
delay(100);
digitalWrite(camt, LOW);
delay(1000);
digitalWrite(relay,LOW);
}
else if (y > camb) //exit if nothing happens
{
digitalWrite(camt, LOW);
digitalWrite(relay,LOW);
x = 0;
y = 0;
}
}
}
//////////IR codes for changing variables//////////

/////flash delay/////
else if (remote.value == 1320358637)
{
fdel = fdel + 1;
button = 1;
}
else if (remote.value == 4294967295 && button == 1)
{
fdel = fdel + 1;
}
else if (remote.value == 1320368327
)
{
fdel = fdel - 1;
button = 2;
}
else if (remote.value == 4294967295 && button == 2)
{
fdel = fdel - 1;
}

/////camera bulb time/////
else if (remote.value == 1320392807)
{
camb = camb + 500;
button = 3;
}
else if (remote.value == 4294967295 && button == 3)
{
camb = camb + 500;
}
else if (remote.value == 1320360167)
{
camb = camb - 500;
button = 4;
}
else if (remote.value == 4294967295 && button == 4)
{
camb = camb - 500;
}

/////IR TRIGGER/////
else if (remote.value == 1320401477)
{
irTrigger = irTrigger + 1;
button = 5;
}
else if (remote.value == 4294967295 && button == 5)
{
irTrigger = irTrigger + 1;
}
else if (remote.value == 1320417287)
{
irTrigger = irTrigger - 1;
button = 6;
}
else if (remote.value == 4294967295 && button == 6)
{
irTrigger = irTrigger - 1;
}

/////keep other buttons from triggering repeat/////
else
{
button = 0; //reset remote button
}
irrecv.resume(); // Receive the next value
}

/////push button/////
if (digitalRead(pButton) == LOW)
{
lcd.clear();
z = 1;
delay(500);
while (z == 1)
{
irt = analogRead(A0); //read ir transistor
//keep LCD stable//
if (irt< 9 && pirt > 10 || irt < 99 && pirt > 100 || irt < 999 && pirt > 1000)
{
lcd.clear();
}
pirt = irt;

lcd.setCursor(2, 0);
lcd.print("IRT MONITOR:");
lcd.setCursor(6,1);
lcd.print("#");
lcd.setCursor(7, 1);
lcd.print(irt);
delay(500);
if (digitalRead(pButton) == LOW)
{
z = 0;
lcd.clear();
delay(500);
break;
}
}
}
/////how fast values change delay/////
delay(125);

}