Can someone explain why LED lights need resistors when connecting to pi. The raspberry Pi is either providing 3.3v or 5v depending on if it's connected to power pins or gpio pins. Your set up would depend on the LED(Cathode or Anode). If the LED supports up to 5 volts why do u need a resistor? Previously I hooked up an Ultrasonic Senor. The pi's general gpio pins only support 3.3v. Therefore needed to hook a resistor from senors trig pin to pi general gpio(input). This is because the Ultrasonic Senor needs 5v to operate. If I am sending a 3.3v signal from pi to LED light then why does it need a resistor before goes to ground?

  • 1
    Oh does it have something to do with current? – z Eyeland Feb 20 '19 at 16:53
  • how is the ultrasonic sensor related to your question? – jsotola Feb 21 '19 at 2:11
  • Diode does not behave linearly (Ohms law). At 1V it is >100MegaOhm, at 1.7V (varies) it is effectively 0ohm short circuit (not quite but for purposes of burning a GPIO it is close enough) and gets even lower as voltage increases. There are equations to determine the equivalent resistance, but you can see how when you turn on a diode by increasing the voltage applied, at some point it becomes a short circuit. One typically uses a resistor to limit short circuit current per ohms law. But other things are possible including fast PWM taking advantage of the intrinsic capacitance if a diode. – crasic Feb 21 '19 at 18:27

A LED only needs between 1.6 V and 3.6V. If you supply a higher voltage the current would increase more than it is good for the LED.

Every Diode (and also an LED) is not linear, that means if the voltage is to high the current would be higher than

  • the current that can be supplied by the Raspberry PI (which could damage the PI)
  • the current allowed for the LED (which could damage the LED)

For a more in-depth background look at https://www.electronics-tutorials.ws/diode/diode_8.html

  • @zEyeland consider selecting the answer as accepted. – GramThanos Feb 20 '19 at 18:19
  • This answer is misleading. LED forward voltage drop depends on LED material and doping and ranges from ~1.3V (infra-red) to ~3.6V (blue) - more for same exotic types. See en.wikipedia.org/wiki/LED_circuit – Milliways Feb 21 '19 at 5:16
  • @Milliways I added a link where the forward voltage is also listed. – Uwe Plonus Feb 21 '19 at 17:20
  • I'd go stronger than @Milliways. This answer is blatantly wrong in multiple respects, including: 1. What Milliways said, 2. LEDs do NOT require a resistor in general (constant current sources, internally limited currents sources, for example, require no resistor). – Brick Feb 21 '19 at 19:22
  • @Brick: The question is clearly related to connecting a raspberry and how to connect a LED to an IO pin. I gave a practical answer. I know that I can drive a LED with a constant current source. In practice you will not use a constant current source but use a resistor to limit the current through a diode (and I talk about any diode, not only LED) because the cost and effort to create a constant current source is in most cases overengineering. I know that there are use cases (like creating high precise current or voltage sources) where a constant current is needed. – Uwe Plonus Feb 22 '19 at 17:05

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