Switching 24v with Arduino 5v

If you don't have space for a transistor, you won't have space for anything else.

You need more space.