You can easily simulate your Arduino code using the famous Proteus ISIS.
You just will have to search for the specific Arduino simulation library for Proteus.
Here you a small tutorial of how to make this thing done:
First, identify the path the Arduino IDE generates the hex file to?
for example if you are using the official IDE you will find the hex file location in the "arduino IDE path/lib/preferences.txt"
Or if you are using Arduino ERW which I recommended the most on windows! So you can simply open the output folder by "Sketch > Copy HEX file as path".
Second, download the Arduino library from Here. Then copy
ARDUINO.IDX to folder "library" in the install directory Proteus.
Third, open ISIS and you should be able to find the component.
Please find this image of the worksheet after finishing the above steps, and simulation works just fine!
And as a head start for you, please find this small memo I prepared for the Arduino Uno Pins Layout:
We can use analog as digital:
00: Rx | Can't be used as I/O if I wrote in the code Serial.begin
01: TX |
03: Interrupt & PWM
10: PWM & SPI
11: PWM & SPI