# How to protect a digital output at HIGH when an override switch pulls it to ground

**URL:** <https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483>\
**Category:** General Guidance\
**Created:** [December 3, 2024, 3:14pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483 "2024-12-03T15:14:21Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 3:14pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/1 "2024-12-03T15:14:21Z")

</div>

I an using an arduino with a typical relay board which needs to be pulled LOW to activate the relay, so is normally at HIGH

> **[Yizhet 5V 8 Channel-Relay DC 5V 230V Relay Shield Module Control Board with...](https://www.amazon.co.uk/Yizhet-Channel-Optocoupler-Raspberry-Channels/dp/B07MJF9Z4K)**
>
> Specification: Material: durable hard PCB Current: AC250V 10A ; DC30V 10A Voltage: DC 5 V Channel: 8 Characteristic: ●5 V 8 channel Relay card interface and each needs 15 -20mA riders current ●Relay output maximum contact is AC250V 10A and DC30V 10A....

I would like to have a manual override switch that pulls the relay input to ground and I know I could use an input pin for that but I would prefer to have manual operation available at all times)

Is there a simple way to protect the output pin so that it stays at HIGH while I am pulling the relay LOW (momentarily - it's for points motors on a model railway)

Here's the idea:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/2/b/92b9df7b62a6ec0553d481abc0d4e51b89693c32.jpeg)

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [December 3, 2024, 3:45pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/2 "2024-12-03T15:45:56Z")

</div>

Have you tried it? It looks ok to me.

---

<div class="post-metadata">

**Author:** ![Dave\_Lowther](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dave_lowther/32/1092885_2.png) [@Dave\_Lowther](https://forum.arduino.cc/u/Dave_Lowther)\
**Post date:** [December 3, 2024, 3:50pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/3 "2024-12-03T15:50:08Z")

</div>

If the pin of the switch is intended to be connected as shown by my red wire, then it wouldn't be a good idea to short the high Arduino pin output to Gnd. Adding a 1k resistor would make it safe. The resistor would limit the current from the output pin to 5mA.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/7/f/c/7fc320eb52599ea1c567d71579cb1bb429f1b724.jpeg)  
[Edit, the 1k resistor may be too high to drive the relay coil if there's no coil driving buffer on the board]

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 3, 2024, 3:51pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/4 "2024-12-03T15:51:22Z")

</div>

Put a pull-up resistor on the input to the relay board, then a diode to the Arduino output pin so that it can only pull the input to the relay board low. The switch is then connected from the relay board input to ground.

The pullup resistor may not be needed, the typical opto-isolated relay board uses the input to provide the ground path for an LED inside the opto isolator.

---

<div class="post-metadata">

**Author:** ![mikedb](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mikedb/32/1098613_2.png) [@mikedb](https://forum.arduino.cc/u/mikedb)\
**Post date:** [December 3, 2024, 3:53pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/5 "2024-12-03T15:53:05Z")

</div>

@johnstrudwick  
Your post title is "Protect digital pin ..."

In your drawing you say "when Arduino is not used"

So which one do you need?

---

<div class="post-metadata">

**Author:** ![ruilviana](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ruilviana/32/722429_2.png) [@ruilviana](https://forum.arduino.cc/u/ruilviana)\
**Post date:** [December 3, 2024, 3:53pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/6 "2024-12-03T15:53:38Z")

</div>

Your relay module is like this?

If so, you can remove R1 put a jumper connecting VCC to pin 1 of 817C,  
and use 1K from arduino and IN1.  
Then connect your switch at IN1 and GND.

By doing this you can put IN1 to GND and not damage the Arduino, because if the pin is HIGH the current will be 5V/1000 = 5mA.  
Hth

 ![Rele_1_Canal_01](https://europe1.discourse-cdn.com/arduino/original/4X/b/6/0/b604db95102d5dca982fb24c8582efb4ec225a15.jpeg)

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 3, 2024, 3:55pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/7 "2024-12-03T15:55:27Z")

</div>

> [@ruilviana](#):
>
> If so, you can remove R1 put a jumper conecting VCC to pin 1 of 817C,  
> and use 1K from arduino and IN1.  
> Then conect your switch conected at IN1 and GND.

Careful, that will leave no current limiting resistor when the switch is used.

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:05pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/10 "2024-12-03T16:05:12Z")

</div>

@mikedb : I want to use the layout in manual mode without a processor but the arduino will still be switched on.

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:06pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/11 "2024-12-03T16:06:30Z")

</div>

@ruilviana : No it isn't like that - I put a link in the post - it's a multi way relay - I just simplified the drawing

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [December 3, 2024, 4:07pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/12 "2024-12-03T16:07:06Z")

</div>

I'd use an SPDT switch. Common terminal to the relay board, one "throw" terminal to the arduino, the other terminal to ground. That way, regardless of arduino state, you can activate the relay without potentially causing damage.

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:07pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/13 "2024-12-03T16:07:53Z")

</div>

@david_2018 : OK but I am new to electronics so can you sketch the circuit and name the diode and the resistor value please ? Thanks

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:09pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/14 "2024-12-03T16:09:19Z")

</div>

@cedarlakeinstruments : The switches are small momentary ones to go onto a model railway control panel, so SPDT would be a) more exepnsive and b) take up too much land space

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:10pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/15 "2024-12-03T16:10:40Z")

</div>

I think I Also read somewhere that these boards have a pullup resistor built in?

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 4:11pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/16 "2024-12-03T16:11:56Z")

</div>

@Delta_G : Sure but I am new to electronics so which diode and how would it be wired?

---

<div class="post-metadata">

**Author:** ![ZX80](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zx80/32/643687_2.png) [@ZX80](https://forum.arduino.cc/u/ZX80)\
**Post date:** [December 3, 2024, 4:35pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/17 "2024-12-03T16:35:41Z")

</div>

> **[6Pin 5.8x5.8/7x7/8x8/8.5x8.5mm Latching or Momentary PCB Push Button Switch...](https://www.ebay.com/itm/335401964998)**
>
> Press Force: 250±50g. Good Good quality.

6Pin 5.8x5.8/7x7/8x8/8.5x8.5mm Latching or Momentary PCB Push Button Switch DPDT

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [December 3, 2024, 5:29pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/18 "2024-12-03T17:29:57Z")

</div>

Put the override switch on the contact side of the relay.

---

<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:** [December 3, 2024, 7:52pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/19 "2024-12-03T19:52:27Z")

</div>

Diode OR gate !

 ![IMG_6358](https://europe1.discourse-cdn.com/arduino/original/4X/7/6/c/76c8943ed7fd845683dba969a16417813e9b6b68.jpeg)

---

<div class="post-metadata">

**Author:** ![johnstrudwick](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnstrudwick/32/1099305_2.png) [@johnstrudwick](https://forum.arduino.cc/u/johnstrudwick)\
**Post date:** [December 3, 2024, 9:58pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/20 "2024-12-03T21:58:13Z")

</div>

So if I use a diode, what diode would I use and which way would I orient it. (Sorry but not up to speed yet on electronics). Could it be combined with the resistor idea of @Dave_Lowther ?

---

<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:** [June 1, 2025, 9:58pm UTC](https://forum.arduino.cc/t/how-to-protect-a-digital-output-at-high-when-an-override-switch-pulls-it-to-ground/1328483/21 "2025-06-01T21:58:50Z")

</div>

Closed on June 1, 2025, 9:58pm UTC

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