Sainsmart 1602 LCD shield causes sketch to run incorrectly

Well yes, it is the code that is malfunctioning - but only when the LCD shield is fitted - so there is probably nothing actually wrong with the code but something affects it when the LCD shield is fitted.

In a nutshell, the code works OK on my Uno (without LCD shield) with the card reader connected to pins 2 & 3. For example, I show a 26 bit card to the reader and the code responds on the serial monitor with "26 bits read" and the card information.

If I power down, fit the LCD shield to the Uno, power back up, and run the serial monitor, I will get the message "6 bits read unable to decode" which the sketch is supposed to do of course if it receives anything other than 26 or 35 bits. This will be fairly consistent (sometimes the message is reported twice on the serial monitor for one card read).

So, by just fitting the LCD shield to the Uno, it seems that it has "poisoned" the sketch (or the Uno) - for want of a better term. Once the LCD shield has been removed, the sketch works OK.