Skip to main content

Reply to "IR or Optical Sensors"

And for Leo. I apologize if asking too much from the forum, and please tell me to stop if that is case. But, in looking at your de-bounce routine, I realized I've never written a function that passed data. Mine were "void's"; did some stuff and went back to main program.Started to read about functions but brain hurt. So my question is: Can a general de-bounce function be written that will work for every input to be tested or does a separate one need to be written for each input to be tested (e.g., one for inner sensor1, one for outer sensor1, etc.)? In other words can you just pass the function whatever input value you are testing and then just return a T or F--so just one function instead of 10 or more similar functions.

Yes. The debounce function that I posted above will do that. To use it, you just tell it which sensor you want to read:

if (sensorTriggered(innerSensor1)) { . . .

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×