Originally posted by Jakob.Sand
View Post
Greig
Sent from my HTC One using Tapatalk
If this is your first visit, be sure to check out the FAQ. You must register before you can post.
IMPORTANT: Your first post will be checked for appropriate content. This may take a bit of time.
If (input signal == LOW) { wait for 500ms if (input signal still is LOW) { send status to homeseer } else { do nothing with this input } }
//********************************Input Setup******************************* byte InPinArray[30] = { 0 }; byte Debounce = 5000; byte count = 0; byte NoOfInPins = 0; int InStateArray [(sizeof(InPinArray) / sizeof(InPinArray[0]))]; unsigned long PrevDebounce [(sizeof(InPinArray) / sizeof(InPinArray[0]))]; void InputCheck(){ byte pinread; for (count=0;count<NoOfInPins;count++) { if(millis() - PrevDebounce[count] > Debounce){ pinread = (digitalRead (InPinArray[count])); if (InStateArray[count] != pinread){ InStateArray[count] = pinread; PrevDebounce[count] = millis(); SendByte(BoardAdd); SendChar(" I "); SendByte(count+1); SendChar(" "); SendByte(pinread); Sendln(); } } } }
case 'I': pinMode(Byte4, INPUT); digitalWrite(Byte4, HIGH); if (Byte3 > NoOfInPins){ NoOfInPins = Byte3; } InPinArray[Byte3-1] = Byte4; break;
//******* modification for input errors **************** 20151026 Alex Houben //*********************************Input Setup******************************* byte InPinArray[30] = { 0 }; byte Debounce = 300; byte count = 0; byte NoOfInPins = 0; int InStateArray [(sizeof(InPinArray) / sizeof(InPinArray[0]))]; unsigned long PrevDebounce [(sizeof(InPinArray) / sizeof(InPinArray[0]))]; void InputCheck() { byte pinread; [B] byte pinread2;[/B] for (count = 0; count < NoOfInPins; count++) { if (millis() - PrevDebounce[count] > Debounce) { pinread = (digitalRead (InPinArray[count])); [B] for (int w = 0; w < 10; w++) { delay (1); pinread2 = (digitalRead (InPinArray[count])); //digital read is approximately 9ms if (pinread != pinread2) { return; } }[/B]
Comment