I am new to Arduino. The digital pins can be configured as output (https://www.arduino.cc/en/Tutorial/DigitalPins) for triggering some sensors. I am now setting a digital (output pin), say no. 7,which is connected to the in1 pin of a SRD relay (https://blog.siliconstraits.vn/relay-what-is-it-and-how-to-use-it/): enter image description here

I am not very clear about the direction of current flowing in the wire connecting the arduino digital pin to in1. To my understanding, when digitalWrite(pin, HIGH), no current flow into the arduino pin, the relay is not triggered, while digitalWrite(pin, LOW), the current flow into the arduino, and the relay is triggered. Please correct me if I am wrong. Thanks.

  • You are not driving the relay directly, are you? – Edgar Bonet Jun 27 '19 at 14:35
  • I updated the post. – jingweimo Jun 27 '19 at 14:46
  • 1
    In your question, you mention connecting the Arduino to a relay, yet in the figure, you show a relay board. That's not the same! Please clarify. If using a relay board, please link to the datasheet or the supplier's product page. – Edgar Bonet Jun 27 '19 at 14:50
  • I consider using a diode in my circuit, so I need to the current flow direction. – jingweimo Jun 27 '19 at 14:51
  • 2
    you did not answer my first question – jsotola Jun 27 '19 at 17:47

When you set a pin to HIGH then that pin will provide 5V. When you set a pin to LOW then that pin will be set to 0 volts. Which direction the current flows depends on what is at the other end of the wire. Current always flows from higher voltage to lower voltage. If you set a pin to HIGH and the thing it is connected to is at ground then current will flow out of the pin towards ground. If you set a pin to HIGH but the thing it is connected to is already at 5V then no current flows. If you set a pin to LOW and the thing it is connected to has some positive voltage then current will flow to the pin. If you set the pin to HIGH (5V) but the thing it is connected to has more voltage than that (say 10V) then current will flow towards the lower voltage and into the pin, probably damaging the Arduino in the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.