Signal inverter

GoingForGold:
I don't really understand for what this first resistor is needed. Could someone explain me this? Would my solution work?

Arduino pins have a limit of 40mA.

The resistor prevents more than this coming out of the Arduino pin (which can damage it).