I'm using the digital I/O pin as a drain.
Without seeing a wiring schematic it is impossible to know what you are doing.However the 40mA limit and 20mA guidance values apply whether the current is flowing into or out of an I/O pin.Just think about it - how tiny are the circuits inside the Atmega328 chip?...R
Your diagram in Reply #9 does not show where the Arduino gets its power.
I would never connect a motor directly to an Arduino I/O pin because, in addition to too much current, motors can generate very high voltage spikes - far in excess of 5v.
What's the correct way to do this?