Arduino noob,
How do you filter out certain digital signals from a input? If I am accepting signals from a sensor but I do not need a function performed on every one how do I filter out the signals I dont need?
Arduino noob,
How do you filter out certain digital signals from a input? If I am accepting signals from a sensor but I do not need a function performed on every one how do I filter out the signals I dont need?
Are you asking about how to do a digital low/high/band pass filters?
Or are you asking how to ignore certain inputs?
How to ignore certain inputs..
Either don't read the inputs, or don't act on them.
Post your code, using code tags, so that we have some idea what you asking about.
You have to be more specific about the nature of your 'sensor'.
For digital input pins and analog input pins you just don't bother to read them if you don't need the data. For serial streams you can read the data and not process it any further when you don't need the data. For other forms of 'sensor' the rules might be different but it is almost always one of those two: don't read or read and ignore. The read and ignore is necessary if the signal is buffered and you have to read the un-needed data to make room for the needed data.
Read this, paying especial attention to the chapter on recursive filters.
Or do this free MIT course.
The sensors would be a photo eye receiver and transceiver. If it takes an object lets say one second to completely pass through the beam then ignore the signal. If it takes say three seconds for the object to completely pass through the beam then accept the signal. Can I do that with a digital signal or does it need to be analog?
Use the millis() function to time the passage and make decisions accordingly.
It does not matter much whether you use digital or analog inputs.
Study the Blink Without Delay example that comes with the Arduino IDE for hints.
davidb789:
The sensors would be a photo eye receiver and transceiver. If it takes an object lets say one second to completely pass through the beam then ignore the signal. If it takes say three seconds for the object to completely pass through the beam then accept the signal. Can I do that with a digital signal or does it need to be analog?
Your definition is digital. It's either in the beam (e.g. = 1) or not in the beam (e.g. = 0).
A few tweaks to this debounce code and you should be good to go.
if there is no object in the beam, then:
make a note that last time we executed the loop, there was no object in the beam
otherwise,
if last time we executed the loop, there was no object in the beam
(this means that an object has just entered the beam)
make a note that last time we executed the loop, there was an object in the beam
make a note that we have not detected the object yet
make a mote of the current time right now (millis)
otherwise (ok, there is an object sitting in the beam),
if it has not yet been three seconds since we detected the object entering the beam
do nothing
otherwise, if we have not detected the object yet
(yay! The object hs now bean in the beam for 3 seconds)
do whatever needs to be done when an object is detected
make a note that we have now detected the object
otherwise
do nothing (the object is sitting in the beam, but we have already dealt with it)