# Arduino Digital Input reads incorrectly when SF Xbee shield is installed

**URL:** <https://community.sparkfun.com/t/arduino-digital-input-reads-incorrectly-when-sf-xbee-shield-is-installed/37311>\
**Category:** Other Radios\
**Created:** [July 16, 2019, 4:02pm UTC](https://community.sparkfun.com/t/arduino-digital-input-reads-incorrectly-when-sf-xbee-shield-is-installed/37311 "2019-07-16T16:02:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgrenoble1](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@cgrenoble1](https://community.sparkfun.com/u/cgrenoble1)\
**Post date:** [July 16, 2019, 4:02pm UTC](https://community.sparkfun.com/t/arduino-digital-input-reads-incorrectly-when-sf-xbee-shield-is-installed/37311/1 "2019-07-16T16:02:58Z")

</div>

My arduino digital input 2 defined as the LSB reads a correct 1 when 5V is applied to it and 0 when no voltage is applied. When the shield is added, it reads a 3 regardless if 0V or 5V is applied to the digital input LSB. Below is the code. The circuit is a wire from 5V to Digital Pin 2.

/Create and Define Global Variables

int dipPins = {5, 4, 3, 2}; // DIP Switch Pins

int Address;

void setup()

{

Serial.begin(9600);

int i;

for(i = 0; i\<=3; i++){

pinMode(dipPins\*, INPUT); // set the digital pins (defined above) as input\*  
_//digitalWrite(dipPins, HIGH); // set internal pullup resistor on_  
 _}  
 }  
 void loop()  
 {  
 Address = address();  
 Serial.println(Address);  
 delay(1000);  
 }  
 //Read state from DIP Switch (4 positions used)  
 byte address(){  
 int i,j=0;_

 

_//Get the switches state  
 for(i=0; i\<=3; i++){  
 j = (j \<\< 1) | digitalRead(dipPins); // read each input pin  
 }  
 return j; //return address  
 }_

---

<div class="post-metadata">

**Author:** ![n1ist](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@n1ist](https://community.sparkfun.com/u/n1ist)\
**Post date:** [July 16, 2019, 6:03pm UTC](https://community.sparkfun.com/t/arduino-digital-input-reads-incorrectly-when-sf-xbee-shield-is-installed/37311/2 "2019-07-16T18:03:50Z")

</div>

Depending on the position of the switch, D2 on the XBEE shield is used for software serial RX from the XBEE. It also has a level shifter and an LED and resistor to 3v3. I would choose a different pin for digital use (D3 is used for soft serial TX, so I would stay away from that one as well).

/mike
