Resistor before or after led: does it matter?

i

no, if the resistor is in serie with the led: no problem!

Depends what the yellow wire is connected to........

The resistor and the photo cell make a voltage divider. One side of the resistor is connected to +5v, one side of the photo cell is connected to Gnd. The opposite sides of both the photo cell and the resistor are tied together - and connected to the yellow wire. As the photo cell resistance changes, the voltage across it changes because of the resistor connected in series. If you changed where the yellow wire is, you'll be connected to +5 or Gnd. If you eliminated the resistor and connected the photo cell from +5 to Gnd, only the current through the photo cell would change. Adding the resistor to the circuit results is a change in voltage across the resistor, and across the photo cell. As the voltage across the resistor increases, the voltage across the photo cell decreases, and the inverse is true as well. The voltage across resistor and the photo cell will always equal the supply voltage: +5 volts. Hope this helps.

Genesis92:
no, if the resistor is in serie with the led: no problem!

From a theory point of view, it makes no difference. However, there is sometimes a practical reason for connecting the resistor to 5V. Imagine that in a project, the led is a little way from the circuit board, perhaps mounted through the front of a case, with a pair of wires connecting the led back to the board. If one of those wires connects direct to 5V, there is a risk of a serious short circuit which could cause damage. However, if the resistor is connected to 5V, then neither of the wires to the led connects direct to 5V, so if s short circuit happens, the resistor limits the current that could flow to a low level.

The same applies when using sensors like ldr in a voltage divider. The ldr might need to be located away from the circuit board on a pair of wires. Better to have the ldr between the arduino input and ground, and the fixed resistor between 5V and the Arduino input. Again, this avoids having a wire leading away from the circuit board that connects directly to 5V.

Paul

I agree with PaulRB it depends of your application too :slight_smile: