Sound flash trigger - HELP needed + video

Hello everyone!

I´m beginner as far as circuit building is concerned. Some interesting problems occured, so i think that the best thing is to give you in detail description of my project: MY GOAL is to build sound trigger for camera flash. During my build, i followed some online descriptions of simmilar projects and build my own configuration.

1. At first, as shown in video 1, the trigger worked perfectly. As seen in code below, you hook up arduino, press button, LED turns on-to show you that it is ready, and when you make some noise, which is louder then treshold, the flash triggers and then light turns off. It worked perfectly.

When I moved my board in room where I wanted to take some pictures, I hooked arduino to my laptop. Just in case I launched arduino 1.0 software. I made sure that the port was the right one, and that it powers my arduino nano corectly. - that probably wasn't necesarry, but I wanted to be sure.

2. Then i set everything up. As shown in video 2: I hook up arduino, it turns on, but then the LED light turns on without any press of my button??? When sound goes above treshold, nothing happens. I try to push button, just in case. Then i try again to make some noise above treshold and nothing happens. Flesh doesnt trigger and LED light stays on. Something isn't right.

Here is my scheme:

The code is the same in video 1 as in video 2. Nothing was changed.

#define BUTTON_PIN 5
#define FLASH_TRIGGER_PIN 2
#define SENSOR_PIN 0
#define LED_PIN 10
#define STANDBY 0
#define ACTIVE 1
#define SENSOR_THRESHOLD 0

int mode = STANDBY;
long flashDelayMS = 10;

void setup() {
    pinMode(BUTTON_PIN, INPUT);
        pinMode(FLASH_TRIGGER_PIN, OUTPUT);
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, HIGH); 

}


void loop() {
    if (digitalRead(BUTTON_PIN) == HIGH)  
    {
        mode = ACTIVE;
        digitalWrite(LED_PIN, HIGH); 
    }
    if ((mode == ACTIVE) && (analogRead(SENSOR_PIN) > SENSOR_THRESHOLD)) //
    { 
        delay(flashDelayMS);
        digitalWrite(FLASH_TRIGGER_PIN, HIGH); 
        delay(50);
        digitalWrite(FLASH_TRIGGER_PIN, LOW);
        mode = STANDBY;
        digitalWrite(LED_PIN, LOW); 

    }
}

Picture of build circuit with my components: On the left side you see amplifier circuit with microphone hooked up to it. In the centre is optoisolator, on which the flash is connected to. On the right side you see Arduino nano, LED light, and the switch in the right upper corner.

I really apreciate all your help! Thank you in advance, kotk.

sounds(!) to me like something got moved when you relocated to the second room cheeck your wires carefully

mmcp42: sounds(!) to me like something got moved when you relocated to the second room cheeck your wires carefully

Thank you very much for your answer. I triple ckecked it and everything is in place. I even replaced all the wires, diodes, capacitors with new ones. Just to be sure, I changed the pins on arduino, but still doesn't work.

your button that starts everything
how is it wired?
you don’t seem to have a pulldown to hold it low, so it will probably float high?

so any noise may well give a false HIGH

suggest you either add a pulldown, or better still
flip the button so it shorts to ground and use an internal pullup to hold it high until pressed

Okay, I don't know if I understand. Could you supply me with a scheme how the switch would look like if it were as you said. And thank you for suggestion.

EDIT: I tried to google pulldown button, and i found out that on that scheme, there was small resistor connected to the same pin as the button. I attached resistor as described. Now the light turns off when I clap, but flash doesnt trigger. Strange.

EDIT2 I found a scheme, here's a picture:

what I would do is: a) swap the resistor and switch b) change the code to check for LOW instead of high c) then do away with the rsistor and use the internal pullup resistor

you do that using digitalWrite(buttonPin, HIGH);