3

So I have a PCB with an LCD hooked up along with a 595 shift register. Unfortunately, when I designed the board I didn't realize that the LCD library used SPI, which on the Arduino Uno is pins 13-10. Therefore, the system overrides the pin 12 for the DHT and it returns nan.

The LCD library I used is here: https://playground.arduino.cc/Main/LiquidCrystal

I've tried modifying the pins_arduino.h on line 40 to set the MISO pin to something else. When I debug the MISO value with serial it prints the value I set it to, however it has no effect on the DHT (still returns nan).

So I'm in a sticky situation because literally every single pin is in use except for 0 and 1, and I've everything is kind of set because I've already made my PCB.

Is it even possible to change the MISO pin, if so, am I going about it the right way?

mr-matt
  • 135
  • 4

1 Answers1

5

How To Reassign The MISO Pin?

You can't. The ATmega328P used on the Arduino Uno only has one SPI peripheral, and its I/O pins cannot be reassigned.

As long as the SPI peripheral is active, pin PB4 (pin 12 on the Arduino Uno) is forced to act as an input, regardless of any other configuration on the device. This means that you will need to temporarily deactivate the SPI peripheral while you are communicating with the DHT sensor. The easiest way of doing this will be to call SPI.end() before communicating with the sensor, then calling SPI.begin() afterwards to return the SPI peripheral to its previous state.

Alternatively, you may want to consider using different hardware to reduce your pin congestion. In particular, if you can make the A4 and A5 pins available, you could replace the HD44780 display and DHT temperature sensor with I2C equivalents.

  • Also, if you reassign these pins, you need to take care that your hardware is okay with writing a bootloader through SPI. You may need additional logic for protection here. – Simon Richter Aug 15 '18 at 02:56
  • @SimonRichter This is an Arduino board. The bootloader is already installed, and shouldn't need to be updated. –  Aug 15 '18 at 03:49