Pullup configuration
Posted: Mon Dec 16, 2013 5:59 pm
When I tried to use a magnetic switch with built in pull-up, I had to change the code for the pull-up to work. I don't know if it is an old IDE to use +14 for pull-up?
I have earlier used PULLUP directly on the digital inputs, and it worked after removed "+14" these two places (the old code is commented).
I have earlier used PULLUP directly on the digital inputs, and it worked after removed "+14" these two places (the old code is commented).
- Code: Select all
void configureStatusPin(int pinNumber)
{
#if defined(STATUS_STRATEGY_3VCLOSED_5VOPENED) || defined(STATUS_STRATEGY_5VCLOSED_3VOPENED)
pinMode(pinNumber, INPUT);
#elif defined(STATUS_STRATEGY_NORMALLY_CLOSED) || defined(STATUS_STRATEGY_NORMALLY_OPENED)
//pinMode(pinNumber+14, INPUT_PULLUP); // addressing analog pins as digital pins (+14)
pinMode(pinNumber, INPUT_PULLUP); // addressing analog pins as digital pins (+14)
#endif
}
//----------------------------------------------------------------------------------------------------
boolean isOpen(int pinNumber)
{
#if defined(STATUS_STRATEGY_3VCLOSED_5VOPENED) || defined(STATUS_STRATEGY_5VCLOSED_3VOPENED)
int status = analogRead(pinNumber);
#elif defined(STATUS_STRATEGY_NORMALLY_CLOSED) || defined(STATUS_STRATEGY_NORMALLY_OPENED)
//int status = digitalRead(pinNumber+14); // addressing analog pins as digital pins (+14)
int status = digitalRead(pinNumber);
#endif