Triggering 5VDC Relay Using an "if...else" Command
I am currently trying to trigger a 5 VDC relay and LED using an "if...else" command. I have attatched the code that I have written thus far. Also pictured is me testing the relay with the 5VDC Power source from the UNO R4, and then the relay connected to digital Pin 4, with the output value above 200. Am I missing something in my code or could it be that the output voltage of the digital Pin is not enough to trigger the relay on my board?



5 Replies
I can't read what voltage your relay is but you should not drive an inductive load directly from a pin
I cannot take a picture of the relay at the moment but it says it’s a 5VDC relay. Is there another way I would be able trigger a relay if not directly from the digital pin? I am trying to trigger a larger voltage pulse using an Arduino Opta but was testing the code with the UNO R4.
If it is normal relay, your Arduino probabely cannot offer needed current. Arduino may survive 40mA via one pin for one moment, when some other criteria are met, but it should not be used regulary. Many relays require way more to work.
I would suggest to not use more than 10mA from/to pin and I would always use transistor (or some another device) to manipulate realys from Arduino (the same goes for motors and all inductive or capacite loads )
I had a feeling the amplitude was an issue but wasn’t sure. Thank you for your answers everyone y’all have been very helpful. I’ll have to post progress as I figure out the solution to this.
