Project

General

Profile

Feature #3

The state of the output pin becomes HIGH (5V) when configuring the pin as output.

Added by Michel Gauvin over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
10/19/2020
Due date:
% Done:

100%

Estimated time:

Description

The relay are changing state at boot, which is unwanted behavior. Try the following:

https://forum.arduino.cc/index.php?topic=568603.0
So you're saying that setting them low turns the relay off - it just doesn't happen immediately when your sketch runs? That's expected, because during the time right after a reset, the bootloader runs, and during that time, the pins are INPUT. If the relay board has them connected to the gate of a mosfet (not unreasonable) the pins are floating and will pick up noise from the environment, potentially going high. To prevent this, use a pulldown resistor (10k should be fine, but really anything within an order of magnitude of that is fine) between the relay pins and ground, this will hold the pin in a defined state when it's not being driven.

#1

Updated by Michel Gauvin over 5 years ago

  • Subject changed from Test the state of the relay at boot. to The state of the output pin becomes HIGH (5V) when configuring the pin as output.
#2

Updated by Michel Gauvin over 5 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied the following solution.

-----------
The solution that mitigated the above glitch in my case (ATTiny85 / Digispark Board) was, as Edgar Bonet pointed out above, going through the INPUT_PULLUP phase:

pinMode(ch2, INPUT_PULLUP);

pinMode(ch2, OUTPUT);

digitalWrite(ch2, HIGH);

https://arduino.stackexchange.com/questions/66654/what-is-the-default-setting-for-a-digital-output-pin

Also available in: Atom PDF