I have a analog inputs to my Uno that I am cleaning up and using to keep a digital pin high until the output drops to zero. At this point I want to stop reading that input because it may come back up after being low for a short time. Is there any way to set a variable that can be triggered by that first zero that prevents the loop from sending the digital pin high from then on? Like a latch of some sort, or could I use an interrupt somehow?
Asked
Active
Viewed 37 times
1
1 Answers
0
You've already described what you need to do. Just set a boolean variable. It really couldn't be easier.
boolean runThisPart = true;
void loop() {
if(runThisPart) {
// this part only runs if runThisPart is true
// if something happens and you don't want
// to run this part anymore then
if(some-condition){
runThisPart = false;
}
}
// The rest of your code can also set runThisPart
// to true or false to turn that section on or off.
}
Delta_G
- 3,270
- 2
- 10
- 24
ifto compare that value. – Majenko May 14 '20 at 10:54== 0and read before settings the output to high. – towe May 14 '20 at 11:00