Simple delay camera trigger

Hi,
I wonder if some kind soul could point me in the right direction here, I thought this would be one of the simplest things you can do with an arduino (and it probably is) but I've spent an embarrassing amount of time trying and failing at different approaches.

I need to build a box for a timelapse project that takes one momentary input (from an intervalometer) and momentarily triggers one relay then 30 seconds later momentarily triggers a second relay, it would be nice to have an LED light up between these two points. The hardware works fine, and I've gone back to looking at the blink code with delay but can't get the outputs to be momentary.

Many thanks,

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 9;     // the number of the pushbutton pin
const int FlashRelay =  10;      // the number of the LED pin
const int LED =  11; 
const int CameraRelay =  12;


// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
 
  pinMode(FlashRelay, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(CameraRelay, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW) {
   
 
    digitalWrite(FlashRelay, HIGH);
      delay(100);   
    digitalWrite(LED, LOW);
 
    digitalWrite(CameraRelay, HIGH);
  
    
  } else {
   

    digitalWrite(FlashRelay, LOW);
      delay(100);
    digitalWrite(LED, HIGH);
      delay(30000);
    digitalWrite(CameraRelay, LOW);
      delay(100);
  }
}

(deleted)

(deleted)

Assuming you have a 10k pulldown resistor on pin 9 so it's not floating and causing false fires when the button is not pushed?

spycatcher2k:
Full sketch

// constants won't change. They're used here to

// set pin numbers:
const int buttonPin = 9;     // the number of the pushbutton pin
const int FlashRelay =  10;      // the number of the LED pin
const int LED =  11;
const int CameraRelay =  12;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup()
{

pinMode(FlashRelay, OUTPUT);
 pinMode(LED, OUTPUT);
 pinMode(CameraRelay, OUTPUT);
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);
}

void loop()
{
 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
 if (buttonState == HIGH)
 {
   digitalWrite(FlashRelay, HIGH);
   delay(100);
   digitalWrite(FlashRelay, LOW);
   digitalWrite(LED, HIGH);
   delay(30000);
   digitalWrite(CameraRelay, HIGH);
   delay(100);
   digitalWrite(CameraRelay, LOW);
   digitalWrite(LED, LOW);
 }
}

Thanks so so much! Lifesaver!

I do have a pulldown resistor.

One weird thing (too clueless me), the relays I have switch off on HIGH so I tried reversing LOW to HIGH on the code you posted, which works great except when the arduino is reset both relays come on, and stay on until after the switch is triggered?

Hopefully this will lead to some awesome long duration timelapse.
Cheers,

Try this:

void setup()
{
digitalWrite(FlashRelay,HIGH);
pinMode(FlashRelay, OUTPUT);
pinMode(LED, OUTPUT);
digitalWrite(CameraRelay,HIGH);
pinMode(CameraRelay, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

outsider:
Try this:

void setup()
{
digitalWrite(FlashRelay,HIGH);
pinMode(FlashRelay, OUTPUT);
pinMode(LED, OUTPUT);
digitalWrite(CameraRelay,HIGH);
pinMode(CameraRelay, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

Great! Thanks so much for your help. With that relay two stays on until the first time the cycle is complete, but I can just by some relays with a HIGH/Low Jumper.

If reply #5 doesn't work, you may need to put pullup resistors (about 4k7) from 5V to the relay pins.