Yes, you can, try using Proteus ISIS for simulating your code...
For full emulation of Arduino, there is a shareware program called VBB (Virtual BreadBoard), I tried it too and it was nice.
Edit: You can check my detailed tutorial here on how to simulate on Proteus ISIS