marklin-users.net community | Forum
Wish to join the discussion?! Login to your marklin-users.net community | Forum accountor Register a new forum account. Or Connect via Facebook
// sensor stuff void checkSensors(){ // check each sensor from 1 to SensorCount int state; const byte debounce = 90; // ms for (byte i=1;i<=SensorCount; ++i) { pinMode(SensorPin[i],INPUT_PULLUP); // do this in case another command set it to OUTPUT.... state = digitalRead(SensorPin[i]); if (state != SensorState[i] && millis() - SensorLastTime[i] > debounce) { // it changed for debounce period SensorLastTime[i] = millis(); if (state==HIGH) { //some stuff }else{ //other stuff } SensorState[i] = state; //keep the new value } // changed } // for each sensor }