[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 :)

Cheers

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.

Thanks!

Your answer 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! :D

Divinity82: 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.

I am facing similar kind of issue, I have linked up 2 arduino nano's for SPI communication.. but the master SCK (Pin13) seems to be loaded by the slave I mean the SCK level drops from 5V to around 2V when its connected to the slave but when that wire is disconnect the level shows a correct 5V clock.. due to this I cannot get the SPI functioning between the two.

I even tried disconnect the led resistor which is connected to PIN13 (SCK) on 1 board (slave) but the problem still persists.

Any suggestions would be highly appreciated.

Pins 11, 12 and 13 are essential for SPI. There are no alternatives. If you need to use SPI then you must leave those pins free for that. However you can talk to several SPI devices using the same 3 pins plus any one other for Chip-Select.

…R

Robin2: Pins 11, 12 and 13 are essential for SPI. There are no alternatives. If you need to use SPI then you must leave those pins free for that. However you can talk to several SPI devices using the same 3 pins plus any one other for Chip-Select.

...R

Yes I have used all those pins for SPI, I mean pin 10, 11, 12 and 13, except than when I connect pin 13 (SCK) of the master to pin 13 of the slave the voltage levels on pin 13 drop as if it is getting loaded by the slave.

Sorry @ARdentLogic, I had not realized you had jumped onto a very old Thread. I thought your Reply #3 was an attempt to help the OP.

Normally the Arduinos are set as SPI masters. You need to change Pin 10 to LOW for it to be a slave. And one of your pair must be a master and the other a slave. I’m not sure if the regular SPI library is intended to work as a slave so you may need to roll your own. However SPI is fairly straightforward.

It would be a good idea to study the Atmega 328 datasheet carefully.

…R

Robin2: Sorry @ARdentLogic, I had not realized you had jumped onto a very old Thread. I thought your Reply #3 was an attempt to help the OP.

Normally the Arduinos are set as SPI masters. You need to change Pin 10 to LOW for it to be a slave. And one of your pair must be a master and the other a slave. I'm not sure if the regular SPI library is intended to work as a slave so you may need to roll your own. However SPI is fairly straightforward.

It would be a good idea to study the Atmega 328 datasheet carefully.

...R

Yes I have taken inspiration from this http://arduino-er.blogspot.in/2014/09/communication-betweeen-arduinos-using.html.

My only worry is why does the Master SPI clock get loaded by the Slave I mean it drops to 2V levels. I have even disconnected the led resistors which were connected to the SCK pin on the arduino Nano but the problem still persists.

ARdentLogic: My only worry is why does the Master SPI clock get loaded by the Slave I mean it drops to 2V levels.

Without seeing either your code (for both devices) or your wiring diagram ...

...R