1234567891011121314151617181920212223 |
- void checkInputStates() {
- for (byte i = 0; i < sizeof(pulseInPins); i++) {
- byte _inputCurrentState = digitalRead(pulseInPins[i]);
- if (_inputCurrentState == LOW && pulseInLastState[i] == HIGH) {
- pulseInLastDebounceTime[i] = millis();
- pulseAlreadyDetected[i] = false;
- pulseInLastState[i] = _inputCurrentState;
- }
- else if (_inputCurrentState == LOW && pulseInLastState[i] == LOW) {
- if ( (millis() - pulseInLastDebounceTime[i]) > debounceDelay && !pulseAlreadyDetected[i]) {
- //if ( (millis() - pulseInLastDebounceTime[i]) > debounceDelay ) {
- pulseInLastDebounceTime[i] = millis();
- pulseAlreadyDetected[i] = true;
- increaseCounter(i);
- }
- }
- else if (_inputCurrentState == HIGH && pulseInLastState[i] == LOW) {
- if ( (millis() - pulseInLastDebounceTime[i]) > debounceRecoveryDelay ) {
- pulseInLastState[i] = _inputCurrentState;
- }
- }
- }
- }
|