I am building an elecromagnetic shutter from an old hard drive and need to control it via an attiny85. Basically I need to be able to have a 2 minute loop that holds my camera shutter open, resetting it to close the shutter at the end of the 2 minutes and starting over.

If the attiny receives a signal from the sensor, it needs to interrupt the loop and trigger the shutter to open (it will shut again by itself instantly) and enable the flash at the same time. After that, it will need to reset and go back to the loop.

Below is the order of desired operations:

void loop()

{

Connect to camera

if 2 mins passes with no activity, reset connection to camera by disconnecting for 1 second

}

{

else

if input goes HIGH

open shutter

Pulse flash x 1

close shutter (should close automatically)

Disconnect camera for 1 second

}

I imagine this should be fairly easy and have put the code below together. Can anyone see any issues with this?

Basically this electromagnetic shutter goes in front of the lens of the camera to enable fast responses for insect photography as no camera is fast enough on its own. It is triggered by a laser oscillating at 38KHz that is aimed into the focal point from one side of the camera and the receiver is aimed at the focal point from the other side. When something hits the focal point a signal is sent to the attiny to do the rest.