[Nano] SPI not working with LCD-screen on pins D8-D13.

Hey guys!

We are three guys from Denmark finishing our Bachelors project here in May, and we have encountered a problem while using our Arduino.

So we have an Arduino Nano with an air pressure sensor connected to the ICSP breakout pins. Also, we connected an LCD-screen on digital pins 8 to 13 (Going 4-bit mode). We want to display the output from our sensor on the LCD-screen, and we NEED to use pins 8-13, as we have already put it onto a finished solderboard for our prototype, and the other pins are reserved for other components.

Now, the screen and sensor output (and whole program) works fine if connected to digital pins OTHER than 8 to 13 eg. 2-7, but once we use those last pins the screen STOPS displaying the right things.

We did some program testing and found that the screen stops working exactly when the line

SPI.begin()

runs.

Now we figure that our problem is, that the ICSP header are internally connected to pins 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK), which are the same ones that the LCD-screen is connected to. Could this be our problem? And if so, since it is too late to make any electronic changes, is there any programming solution we could try?

Hope I made myself clear enough :slight_smile:

Cheers

Yes, you effectively tied the lcd and the pressure sensor to the same pins. Hard to say if there are any ways out without seeing the code and/or schematic. But with these constraints I’m pretty sure you are attached to another object by an inclined plane, wrapped helically around an axis. In other words “screwed”. (Leonard Hofstadter) :wink:

Yeah, well, we actually found a solution thanks to an answer from a poster on the official Arduino Forum.

Here is his response:

Pin 13 is a beast even on the nano/mini. Pin 13 has other dependents that pull down the voltage and generally make it return LOW. There are ways around this such as setting pinmode to input and using an eternal pull down resistor but whenever possible, it is best to use another pin if available.

And my own response:

Thanks!

Your answer helped lead us towards a solution!

We have to start the SPI with .begin() and end it with SPI.end() right after we collected the sensor-data. Afterwards though, we must again reconfigure the pinModes to OUTPUT to all those pins since the SPI library probaly sets some of them as INPUTS.

Now we can finish our project, yahoo! :smiley:

So it went well after all :slight_smile: