ATTiny85 pin used as switch?

I want to close a circuit by changing a pin state and wonder if it can be done.

I have a wire connected to ground and another connected to PIN 0 of the attiny85. Can I short or OPEN the connections simply by changing the state of the pin?

I've tried pinModes INPUT, INPUT_PULLUP, OUTPUT and then changed the digitalWrite to HIGH or LOW and the connections are always shorted. I'd like to find out if I can OPEN the connection as if I've disconnected one of the wires.

Doable??

The answer is yes, but how to do it depends on the circuit itself. You may be able to do it directly or you might need a transistor or even a relay. So show us the circuit in question!

You cannot short or open them, without more conditions.

If the pin is input, it's sort of like it was open - but it can't go above vcc or below ground

If you set the pin output and drive it low, that well try to drive it to 0v; it can only sink 40ma max, (20 max recommended), though, so it's not really like shorting it to ground. But depending on the use case, it may be the same in practical terms

The circuit design is very simple

ATTiny85 physical pins: PIN 8 to 5VCC, PIN 4 to GND, PIN 5 (logically pin 0) has a wire to a light, another wire is connected to GND.

I want PIN 5(logical 0) to be OPEN unless I change that in code. When that condition occurs, I want to short or 'logicly' connect PIN 5 to make the light come on.

Kinda acting like a light switch in your house, you flip the lever and the light comes on. Only in this case the lever is in code. I don't really care if PIN 5 has any power on it or not, it won't matter.

What kind of "light" is that? How is it powered? 110/220V from a wall socket?

Did you read my post? I outlined the conditions under which that will give similar behavior to a switch.

If the light draws 20mA or less (40mA at most), and runs off 5 volts, that will just work.

If the light draws more current or runs at a higher voltage, it would damage the arduino to hook it up like that, and you'll need to use a transistor (either NPN BJT or N-channel FET) to switch the load.

Yes I read it, very nice, good info. However, what I'm looking for is a way to turn OFF the light. Assuming it's a simply bulb connected to PIN 5 and gnd. Normally it would be ON, enabled with 5v. But now, in code, I want to turn it OFF, without disconnecting the wires or light.

Traxxtar:
Yes I read it, very nice, good info. However, what I'm looking for is a way to turn OFF the light. Assuming it's a simply bulb connected to PIN 5 and gnd. Normally it would be ON, enabled with 5v. But now, in code, I want to turn it OFF, without disconnecting the wires or light.

And yet, you still haven't told us the specs of the light? How much current does it use? For that matter, what kind of light is it? Do you have a link to the product page?

It may be as simple as putting the bulb between GND and pin 5, and doing digitalWrite(5,1) to turn it on (putting 5v onto pin 5) and digitalWrite(5,0) to turn if off. But if your light requires more than 40mA (which most light bulbs do - who uses light bulbs anymore though?), this will damage the chip, and you'd need to use a transistor...

Thank you for the info. It's just a little LED light. I need the circuit to be OPEN when the PIN is low, connected when it is HIGH. I'm trying to perform a 'physical' connection of a line through manipulating the PIN level. I can still measure connectivity between GND and PIN 5 regardless of PIN state though, so this may not be doable at all.

I may be better off soldering both wires to a tiny switch, one side GND, the other 5, and open/close the switch based on PIN level. Is there a tiny little switch that will do that?

It's not "just a little LED light".

It has specifications. It has a voltage at which it has to operate, and a current which it draws. If it contains a resistor (or other current limiting circuitry), it will operate over a certain voltage range and draw a specified current. If on the other hand, it has no resistor or other current limiting circuitry, then it will require to be connected with such in order to regulate the current which is specified for it.

And we are not going to - can not - explain how to connect it until you supply all those details.


Or - how do you propose to "open/ close a tiny switch based on PIN level"? :astonished: