Making a "digital fuse" in arduino

Hey everyone!
I was thinking if I could make a digital fuse by having a set value and another that will be the threshold.
for example, I have a set value of 15 volts and a threshold of +2v.
so if the sensor measures it to be higher it will stop the program.

int setVal
int threshold = setVal +2;
if sensorVal > threshold
digitalWrite (LED, LOW);

I think it's possible but I'd like to hear your opinions.

Why not simply try it?

(Once you get it to compile)

Obviously, you won't be applying 15V directly to your Arduino inputs.

I already tried it but without a sensor but it works! I'm still a newbie with arduino, and I was curious how other people would program it. Because there are different ways to type it.

We can't see what you tried, but we know it wasn't what you posted

But it won't...

The snippet you posted would, as part of a full program, make the led's pin go low, but assuming it was part of loop() it would continue round and round until the power went off.

Even if it was in setup() and ran only at startup, the program won't stop- it will continue into loop().

What do you mean by "stop the program"?

oh, this was more like an example. As in "what would you do?" I was more concerned about the threshold part.
I get that if you want the program to fully work you need to do something like:

int count;
int sensorVal;
int setVal;
int threshold = setVal +2;
if sensorVal > threshold AND count == 1
digitalWrite (LED, LOW);

You still need to explain what you mean by "stop the program"

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.