Electronic – arduino – Use unused SPI MISO pin for I/O on ATTiny

arduinoattinyspi

I want to use an attiny85 for a project that will be controlling some LEDs over a pseudo SPI that only needs to use SCLK and MOSI. Is there any way to reconfigure pin 6 (MISO) on the 85 to be used as a digital read/write after configuring SPI? I need 3 digital read pins as well as the 2 for SPI and the only way I can d it is either disable the reset pin, which would than mean I would need a high voltage programmer to program it :(, or use the MISO pin…

Any way to do this?

Best Answer

The SPI MISO function is nothing but a digital input pin.

The question does not specify whether the pseudo-SPI LED peripheral provides a handshake or other data on the MISO line at all. Assuming there is some initial data at set-up if at all, but no further use of the line by the peripheral during normal operation, the following should work:

Connect one of your 3 data source lines, OR'ed with the MOSI coming from the SPI peripheral, into pin 6 of the ATTiny.

During SPI set-up, ignore (or do what's needed with) the signal coming into pin 6. After that, simply read Pin 6 as you would any normal digital input pin.

If the LED peripheral works fine without connecting it to the MISO on the ATTiny at all, then you can skip the OR connection, and simply treat pin 6 as a standard digital input.