Shift registers need 3 digital pins in order to work (data, clock and latch), but Attiny45/85 chips provides 2 digital and 2 analog pins.
Would I use 1 analog pin as digital pin? How?
-
forum.arduino.cc/index.php?topic=170470.0 this can be helpfulMartynas– Martynas2014年12月05日 06:16:46 +00:00Commented Dec 5, 2014 at 6:16
-
well that's an unanswered question i guesswhitenoisedb– whitenoisedb2014年12月05日 07:55:48 +00:00Commented Dec 5, 2014 at 7:55
-
Thats why its in comments i guessMartynas– Martynas2014年12月05日 07:56:13 +00:00Commented Dec 5, 2014 at 7:56
-
Claiming only 2 analog pins must mean that you're using attiny instead of arduino-tiny; I recommend that you use arduino-tiny instead.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月05日 08:15:22 +00:00Commented Dec 5, 2014 at 8:15
2 Answers 2
The ATtinyX5 does not have any analog-only pins; all 5 pins are usable as digital I/O (all 6 if you know what you're doing, but if you need to ask how then you're not ready to do so).
-
well, I mean if I had to declare them as OUTPUT using pinMode(). Should I use digitalWrite() and digitalRead() on them?whitenoisedb– whitenoisedb2014年12月05日 15:28:43 +00:00Commented Dec 5, 2014 at 15:28
-
That's how you use digital I/O with the Arduino libraries, so yes.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月05日 15:29:27 +00:00Commented Dec 5, 2014 at 15:29
As Ingnacio has already pointed out, PB0 to PB4 can be used as digital IO ports without problems. It night be a good idea though not to touch PB6, the RESET
pin.
Btw, this isn't different from an Arduino, where all so-called analog pins can be used for digital output as well.
If you want to drive shift registers from an ATtiny85 using SPI, you might want to have a look at the tinySPI library written by Jack Christensen. Please note that I haven't used this library personally!
-
Thanks. I'll read about SPI. I know attinyX5 uses USI, but communication is possible with that library and SoftwareSerial I guess.whitenoisedb– whitenoisedb2014年12月05日 15:32:03 +00:00Commented Dec 5, 2014 at 15:32