Can output pins be set to HIGH/LOW externally safely?

neroroxxx

Well-known member
Hi all this may be a very silly question but I didn't want to do burn a 4.0 pins if i don't have to.

I have a circuit with a transistor and an optocoupler, basically i have a 4.0 with an output pin sending LOW by default and HIGH when i want the opto to switch, turning that pin from LOW to HIGH will be done using MIDI or thru the serialmonitor.

Now I want to add footswitches to it as well, this is as easy as wiring a footswitch to another pin, however, I'm now wondering if i could just wire the footswitch to the output pin, the footswitch is a momentary SPST switch, one pole will be connected to the teensy pin that controls the opto and the other pin to the 3v pin on the teensy.

The idea is i can set the pin HIGH or LOW via software OR have a mechanical momentary footswitch that will put 3v into that pin.

I hope this questions makes sense, my main concern is: if the pin is currently LOW and i use the footswitch to pass 3v to the pin, will this cause an issue? or if the pin is currently high and i use the footswitch to pass it 3v would this cause any issues?

Screen Shot 2020-10-05 at 3.18.40 PM.jpg


Screen Shot 2020-10-05 at 3.18.31 PM.jpg
 
if the pin is currently LOW and i use the footswitch to pass 3v to the pin, will this cause an issue?

If the pin is configure to OUTPUT mode, then yes, it absolutely can cause an issue. If could damage your Teensy. Even if Teensy isn't damaged, this definitely will stress the pin far beyond what's considered safe & reliable.
 
thank you for your reply Paul, this is why i wanted to ask first, i'll go safe and use another pin for footswitches
 
Couldn’t you instead configure the pin as INPUT_PULLDOWN for low and INPUT_PULLUP for high then directly connect the switch to the pin without it causing issues?
 
Opendrain would work also I think.

As for inputs, if he is driving the pin, that won't work because the pedal will ground and the digitalwrite will apply 3.3v. with open drain it grounds and releases, doesnt apply voltage, so pedal can be inline as well. correct me if im wrong ��

problem is he needs voltage for the opto so.. he needs an independant pin, with INPUT_PULLUP and pedal switch to GND.
 
pinMode OUTPUT_OPENDRAIN is only viable if the switch connects between the pin and GND.

As shown on the 2nd schematic of msg #1, the switch would short the pin to 3.3V. That would damage or over-stress the hardware if the pin is driving logic LOW in either OUTPUT or OUTPUT_OPENDRAIN mode.
 
Couldn’t you instead configure the pin as INPUT_PULLDOWN for low and INPUT_PULLUP for high then directly connect the switch to the pin without it causing issues?

The problem with that would be the Teensy isn't able to switch the optocoupler through the resistors...
Open drain is the acknowledged way to do something like this, its often used for chip reset and error
pins - the error pin would pull reset low, as can external switches, but nothing pulls high except for a
pull-up resistor which won't allow enough current for any damage.

Another approach is adding a diode or two to prevent damaging short-circuit currents when multiple
outputs drive one load.
 
From a maintainability perspective, it's 100% better to do this in software. Suppose you change your mind about how that should work in six months. Do you want to adjust a few lines of code - or do you want to get out your soldering iron and an x-acto knife, and carve up a PCB?
 
Back
Top