Add a warning blink LED by the user (dip switch)

Hi!
I just finish a part of my program and everything work perfectly!!

These’s one thing that I want to add but I dont know how to do that.

I want to have a dipswitch that’s gona add a warning blink LED.

I explain myself.

The program is sensor that control a servo.

For the moment I want to add a warning if the voltage go over X.

BUT, I want to have access to this warning with a dipswitch for changing the value.
It’s possible???

And it’s possible to put this warning in the EEPROM memory?
I dont want to reset the warning averytime.

Thanks.
JC

If I understand correctly, you have a number of elements:

1) An LED appropriately attached to one of the Arduino IO pins to serve as your warning light 2) A dipswitch. Is this a single switch to enable/disable the warning? Or multiple dipswitches making a binary represntation of the value to compare against for the warning threshold? Please explain further. 3) A boolean value stored in EEPROM to indicate the warning has been triggered. How does this get cleared once the warning has been triggered?

arduinodlb: If I understand correctly, you have a number of elements:

1) An LED appropriately attached to one of the Arduino IO pins to serve as your warning light 2) A dipswitch. Is this a single switch to enable/disable the warning? Or multiple dipswitches making a binary represntation of the value to compare against for the warning threshold? Please explain further. 3) A boolean value stored in EEPROM to indicate the warning has been triggered. How does this get cleared once the warning has been triggered?

Sorry I just check my first post and it's not really clear..loll

So the switch need to add a value. For exemple the warning is set to let say 10. When it's 10 or more the led is flashing. When it goes bellow 10 the led stop flashing.

The dip switch need to add 1 everytime I press it. so if I press once the new threshold will be 11....etc.

I want to store this in the EEPROM because I dont want to press the switch everytime I turn off and on the arduino.

If I set it to 11, I want everytime I reopen the arduino it's already set to 11...

If I set it to 11, I want everytime I reopen the arduino it's already set to 11...

Will it ever need to be decremented instead of incremented, reset back to a starting value or have its upper or lower value limited ?

By the way, what you seem to be describing is not a DIP ([u]D[/u]ual [u]I[/u]nline [u]P[/u]ackage) switch but maybe a push-button.

UKHeliBob: Will it ever need to be decremented instead of incremented, reset back to a starting value or have its upper or lower value limited ?

By the way, what you seem to be describing is not a DIP ([u]D[/u]ual [u]I[/u]nline [u]P[/u]ackage) switch but maybe a push-button.

Yes your right it's more a push button.

I think the best way to do it it's to have a separate push button for decrements

The value will be between 0 and around 30 so 2 push button will be better.

I am sorry to be awkward but how will the user know what the threshold is ?

UKHeliBob: I am sorry to be awkward but how will the user know what the threshold is ?

It's gona be control by a servo motor. So the servo angle will change and tell the user what's the new threshold for like 2-3 second and go back to the original point.

It was my first idea. Or Ill put a little LCD and write the value of the threshold.

Now that we nearly have the specification it is time for you to start writing some code. Forget your main program for now, whatever it is, and write a small program that reads 2 digital inputs. When one of them goes LOW increment a variable, when the other goes LOW decrement the variable. Whenever the variable changes print it to the Serial monitor. Don't worry about checking the limits of the variable's value at the moment.

Things you need to know how to do : Detect when a pin goes from HIGH to LOW. See the StateChangeDetection example in the IDE Change the value of a variable - easy peasy Printing to the Serial monitor - easy peasy

UKHeliBob:
Now that we nearly have the specification it is time for you to start writing some code. Forget your main program for now, whatever it is, and write a small program that reads 2 digital inputs. When one of them goes LOW increment a variable, when the other goes LOW decrement the variable. Whenever the variable changes print it to the Serial monitor. Don’t worry about checking the limits of the variable’s value at the moment.

Things you need to know how to do :
Detect when a pin goes from HIGH to LOW. See the StateChangeDetection example in the IDE
Change the value of a variable - easy peasy
Printing to the Serial monitor - easy peasy

Good thanlks!
I’m at work now so Ill try this at home.

I’m gona try instead to print to the serial monitor to play with the angle of the servo.
I can probably go with the same thing, like add a number of value to the servo so it will go at the good angle.

Another question. It's possible to add a if condition to a loop?

Exemple if my warning loop is ON for more than one second, another loop will go ON?

Exemple if my warning loop is ON for more than one second, another loop will go ON?

The answer is yes, but you are using the word loop in an odd way. If you expressed it as "if a condition is true for more than one second them an action will happen" it would make more sense, Note that you cannot use delay() to do the timing of the one second.

If your main program uses delay() then you will probably need to rethink that too to avoid it holding up the reading of the buttons that you are now considering adding.