1

Let's say I configured GPIO 2 as an output pin to control a 5 V solid state relay. When I set GPIO 2 to HIGH (True/ON) the relay will turn off and when I set GPIO 2 to LOW (False/OFF) the relay will turn on. It's an obvious behavior so I can write my program according to the relay. The problem is I want to turn on one 3 V small LED with the relay (so when the relay turns on the LED should turn on and when the relay turns off, the LED should too).

In order to do that I took the 3V3 from my Raspberry Pi and gave it to the LED and another side of LED put into GPIO 2 and it worked as expected.

I just want to know is it the correct method what I did (I don't think so)? If not what can I do to achieve that.

1
  • 1
    @Aurora0001 Thank you so much for editing my question. Now it is more easy to understand. Commented Feb 26, 2018 at 4:35

1 Answer 1

1

When it comes to circuit designing, you don't have to worry about correct method. You have to worry about efficiency.

Instead of dragging a 3V from GPIO you can simply hook the LED (+) Positive to the relay output and add a 330 ohms resistor from ground to the LED (-) Negative.

3
  • Thanks Jagan for the answer. The relay is controlling 240v AC appliances so i cant do that and if i increase the resistor value i don't think this will be efficient. Please guide me if i am wrong. Commented Feb 26, 2018 at 4:25
  • Hello Sayed Zisha Ali, I though the relay was 6v. Instead of connecting the LED directly to the relay, You can hook another wire from GPIO2 to a transistor and create a NOT gate. Which looks something like this http://www.dummies.com/
    – user81388
    Commented Feb 26, 2018 at 7:57
  • 1
    Thanks Jagan for the quick reply. I got what you are saying. It seem like it should work for me. Will update you. Commented Feb 26, 2018 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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