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.
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.
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().
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);
}