Stupid NOOB question

Greetings,

I've built a remote shutter for my DSLR using a NANO and HC-SR501 PIR device. The code I wrote runs perfectly. My problem is that I would ike to adjust the delay timings. I would also like to adjust the shot count, which is fixed at 8 shots within a FOR loop. Here is the relevant code. Thank you in advance.

Cheers

void loop() {

int x = digitalRead(pirSensor_1);

if(x==LOW) .

{
digitalWrite(halfPress_FET,LOW);
digitalWrite(shutter_FET, LOW);
digitalWrite(shutterLed, LOW);
digitalWrite(ready_LED, HIGH);
delay(300);

}
else
{

digitalWrite(ready_LED, LOW);

for(int x = 8; x >0; x--) {

digitalWrite(halfPress_FET,HIGH);

delay(900);
digitalWrite(shutter_FET, HIGH);
digitalWrite(shutterLed, HIGH);

delay(100);
digitalWrite(shutter_FET, LOW);
digitalWrite(shutterLed, LOW);

}
}
}

Please use code tags when posting code.

My problem is that I would ike to adjust the delay timings.

Why would that be a problem? Go ahead and adjust them.

jremington:
Please use code tags when posting code.
Why would that be a problem? Go ahead and adjust them.

Yes, and that's the problem. I'm using weatherproof mini toggle switches. How to adjust the delay and shot count using front panel toggles?

Believe me, I've tried everything. For example, I've tried this: delay(a); using an IF statement,and read the switch state, to determine the value of the variable, whih doesn't work. Interestingly, global variables aren't recognized within the IF/ELSE part of the code.

I'll poke around the forum and learn the appropriate method for embedding code snippets.

Cheers,
rc

Gentlemen,

I've been an electrical engineer for close to 50 years. There is a very good chance that I understand things that you don't have a clue about. I've beeen in the electronics manufacturing industry before many of you have been born. A part of my responsibilities is to assist as needed on the factory floor. I don't ever recall being as rude to an associate as I have been here.

Learn something about Ice Cube Neutrino Labratory. The high voltage required by the PMT's? Thats me.

Thanks for nothing.

I wonder... Do I hold the record from my first post to being banned?

There is a very good chance that I understand things that you don't have a clue about.

No surprise there. Most of the people I have met know things that I don't have a clue about, and I will bet that the ones I forgot to ask have some surprises, too.

To your question (which might very cleverly have appeared in your first post):

How to adjust the delay and shot count using front panel toggles?

Easier to use buttons instead: https://www.arduino.cc/en/Tutorial/StateChangeDetection

BTW: do I recall correctly that the mean free path for a visible photon, deep in the Antarctic Ice, is about 700 meters?

iceninephoto:
There is a very good chance that I understand things that you don't have a clue about.

A statement like needs to be handled with great care. It is a two-sided statement. The other side of it reads
"There is a good chance other folk understand things that I don't have a clue about"

The key skill for an experienced engineer is knowing how to put other people in the frame of mind where they are willing to fill the gaps in the experienced engineers knowledge.

...R

I don't ever recall being as rude to an associate as I have been here.

I really can't understand that. Why HAVE you been rude here?

iceninephoto:
How to adjust the delay and shot count using front panel toggles?

The delay part might be easier with an analogRead() of a potentiometer, mapped to a range of delays.

But with toggle switches you could read in a binary number, with 4 switches giving you 16 options including 0.

Just multiply each switches's power-of-2 weighting by its 0 or 1 value when you digitalRead() it, and add them up.

iceninephoto:
There is a very good chance that I understand things that you don't have a clue about.

That's a true statement. Everyone I meet knows things that I don't. And I invariably know things that they don't.

Of course in many cases what those other people know are things I have absolutely no interest in.

iceninephoto:
Learn something about Ice Cube Neutrino Labratory. The high voltage required by the PMT's? Thats me.

And there's an excellent example of something I have no interest in. But if I do ever become interested, I'll try to remember who to ask.

But back to your original problem. How about posting one or two examples of the things you say you've tried and that don't seem to work together with descriptions of what exactly it is that they do? THAT would give us something we might actually be able to help with.

Steve

Or, instead of my binary switch and potentiometer suggestions above, a resistor ladder on a rotary switch might do the trick.

Source with explanation.