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.