# ATTiny85 DigitalWrite on all pins

**URL:** <https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172>\
**Category:** General Guidance\
**Created:** [November 9, 2023, 1:15pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172 "2023-11-09T13:15:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 1:15pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/1 "2023-11-09T13:15:00Z")

</div>

![AT85](https://europe1.discourse-cdn.com/arduino/original/4X/6/e/e/6eea85960d50a3a3626f60278face7accb21d71d.png)

Good day all. It has been a long time since i've been on the forum or used the IDE for that matter. Things sure have changed.

I've attached a schematic of my project. It's actually going to be a business card.

Anyway, I'm just curious to a couple things.  
A) I pretty much did a copy paste from the sparkfun ATtiny85 board. I'm looking for verification or suggestions.  
BJ) can i use all 6 pins as digitalwrite even if data is going to them from usb?  
C) I plan to use a 3.3v coin cell. data sheet for the AT85 suggests that it's possible.

any suggestions, questions, critiques are welcome.

Thank you

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [November 9, 2023, 2:00pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/2 "2023-11-09T14:00:28Z")

</div>

B) No.  
C) It will not run for long. The 270 ohm to the transistor will consume considerable current from the coin cell. The LEDs being on will add current consumption.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 9, 2023, 2:11pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/3 "2023-11-09T14:11:10Z")

</div>

> [@Railroader](#):
>
> It will not run for long

@horkusflux you may want to run this hardware and see if you get the performance you need. Coin cells are happier with light loads.

Will the cell be replaceable?

I am curious about your target cost per business card…

If that transistor is part of the on/off switching, you may find a better circuit using a MOSFET, and perhaps consider using high side switching of Vcc.

Have you measured the off current using your arrangement?

a7

---

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 2:33pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/4 "2023-11-09T14:33:21Z")

</div>

There should be no off current. or at least very very little. The battery is replaceable. only 2 or 3 LED's will be on at any given time.  
I like he mosfet idea.

the idea with the transistor is that once the button is pressed, it will turn on the ATtiny. The tiny will then digital write high to hold it on. once the LED functions are complete it will digital write the transistor low. shutting off the card.

Cost isn't really an issue. these cards will only go to clients that are higher end.  
Not gonna be the card given to every one.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 9, 2023, 2:38pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/5 "2023-11-09T14:38:27Z")

</div>

> [@horkusflux](#):
>
> Not gonna be the card given to every one.

LOL, I figured, either that or have only one on a thread so you can yank it back from the person you gave it to before she pockets it and forgets she ever had it.

But surely you mjst measure the current. I say so because I have been bitten by the thrill of the chase for microamperes in some low power stuff I've built.

The last few draining the cell alla time can be hard to find. Only measuring will confirm you design.

I used it as an excuse to but a better DMM…

a7

---

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 2:39pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/6 "2023-11-09T14:39:20Z")

</div>

for B)  
why no? I'm not using the USB in my code. its only for initial programming.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 9, 2023, 2:42pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/7 "2023-11-09T14:42:19Z")

</div>

> [@horkusflux](#):
>
> for B)

You have everything in front of you there, why not try it? I assume the card isn't going to have the USB stuff.

If it turns out you can't USB program it, can you use a different programmer? I think you can make an ATTiny programmer out of an Arduino board.

a7

---

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 2:42pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/8 "2023-11-09T14:42:46Z")

</div>

Do you have any thoughts for question B in the original post?

---

<div class="post-metadata">

**Author:** ![hammy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hammy/32/238813_2.png) [@hammy](https://forum.arduino.cc/u/hammy)\
**Post date:** [November 9, 2023, 2:47pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/9 "2023-11-09T14:47:51Z")

</div>

I don’t like the idea of switching the negative line - you can get lots of unexpected things happening .  
If you are giving away a piece of electronics with a battery for business purposes, then strictly speaking it needs to meet approvals and carry the appropriate mark ( CE or whatever ) .  
Things like disposal of battery , EMC , access to battery compartment ( can a child easily eat it ?) , consideration of wrong usage etc etc .

This sort of stuff  
“ a) The producer should first consider whether the product needs batteries or whether it can be powered by other means.

b) If the producer is of the view that batteries are required, they should explore whether alternatives to button or coin batteries can be used.

c) If there are no viable alternatives to button or coin batteries, the producer should ensure that the product has a battery compartment that can be securely fastened, and cannot open inadvertently, to prevent a child from removing the batteries.

d) In addition to (c) the producer should make sure that there are sufficiently prominent and clear warning labels on the product, its packaging, and any instructions and/or manual provided with the product.”

---

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 3:47pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/10 "2023-11-09T15:47:32Z")

</div>

Why don't you like the idea of low side switching?  
a mosfet or transistor on the high side will always require power at the base to keep the switch in the "off state". yes?

Thank you for your other insights.

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [November 9, 2023, 4:05pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/11 "2023-11-09T16:05:05Z")

</div>

> [@horkusflux](#):
>
> BJ) can i use all 6 pins as digitalwrite even if data is going to them from usb?

The following Digispark ATtiny85 Board indicates the possibility of using all the 6 pins as IO lines.  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/6/0/a/60a1281b1f6978b6d5db686127d34526620b7df7.png)

---

<div class="post-metadata">

**Author:** ![horkusflux](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horkusflux/32/1013044_2.png) [@horkusflux](https://forum.arduino.cc/u/horkusflux)\
**Post date:** [November 9, 2023, 4:12pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/12 "2023-11-09T16:12:22Z")

</div>

That's the data I was using.  
I'm curious to if its actually ever been done.

I did order one of these and as soon as I put it in my USB slot with the IDE open.  
It self wrote it's own code that repeated "thank you for your purchase"

weirdest thing i've ever seen.

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [November 9, 2023, 4:42pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/13 "2023-11-09T16:42:40Z")

</div>

I have a Digispark Attiny85 Dev Board. I have uploaded the following sketch to drive a LED connected at PB4 (D+ of USB) and the sketch works well.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/c/8/2/c822f91a881da3861f1f68f8568f562a9e4bd111.jpeg)

```arduino
#define LED 4

void setup()
{
  pinMode(LED, OUTPUT);
   
  //-------system reset indication-----
  for (int i = 0; i < 3; i++)
  {
    digitalWrite(LED, HIGH);
    delay(200);
    digitalWrite(LED, LOW);
    delay(200);
  }
}

void loop()
{
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}

```

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 9, 2023, 10:24pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/14 "2023-11-09T22:24:51Z")

</div>

Here's a high side MOSFET latching circuit I knew I saw go by recently on this thread

> [@Want to turn on a relay by connecting 2 wires](https://forum.arduino.cc/t/want-to-turn-on-a-relay-by-connecting-2-wires/1171160):
>
> Hello, I am new to this arduino world and I would like to create one project. Please help me to write a program for the below requirement. const int relayPin = 6; // Define the pin connected to the relay module const int firstWirePin = 2; // Define the pin for the first set of wires const int secondWirePin = 3; // Define the pin for the second set of wires bool relaystatus; bool secondwirestatus; void setup() { pinMode(relayPin, OUTPUT); pinMode(firstWirePin, INPUT\_PULLUP); pinMode(sec…

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/3/e/6/3e6d80a4019a1a70f02c19492366740aafd788c0.jpeg)

a7

---

<div class="post-metadata">

**Author:** ![hammy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hammy/32/238813_2.png) [@hammy](https://forum.arduino.cc/u/hammy)\
**Post date:** [November 10, 2023, 1:32pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/15 "2023-11-10T13:32:31Z")

</div>

> [@horkusflux](#):
>
> Why don't you like the idea of low side switching?  
> a mosfet or transistor on the high side will always require power at the base to keep the switch in the "off state". yes?

The problem often you get fugative powering of parts via other earth paths , which causes all sorts of issues .  
If you use the right bits , you don’t need to keep the transistor powered - except via say a 150k resistor feeding a switched off transistor which is about 0mA !

The previous posters circuit is a good one I’ve used a few times .

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 10, 2023, 2:50pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/16 "2023-11-10T14:50:55Z")

</div>

> [@hammy](#):
>
> The circuit the in the previous post

Fixed that for ya'. I wish I could ever have figured out that circuit!

a7

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 8, 2024, 2:51pm UTC](https://forum.arduino.cc/t/attiny85-digitalwrite-on-all-pins/1187172/17 "2024-05-08T14:51:21Z")

</div>

Closed on May 8, 2024, 2:51pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
