Arduino is a great platform, but If you're trying to debug a program with a mix of software bugs and hardware issues, you could use a free helping hand! UnoArduSim.exe allows you to do a real-time test of most Arduino programs (for Uno, and Mega as of V2.8.0) without needing most actual hardware. Supported libraries are: TFT.h, SD.h, Stepper.h, Servo.h, SoftwareSerial.h, Wire.h, SPI.h, OneWire.h, and EEPROM.h (all for the Arduino V1.8.8 release)., as well as some 3rd party libraries for LCD and LED displays.
UnoArduSim provides a virtual target Uno board and allows the user to choose, and interface to, one or more of several types of virtual input/output devices. These include typical hobbyist DC gear-motor, stepper-motor, and servo motors, generic serial devices with selectable baud rate, generic I2C and SPI slaves, as well as I2C and SPI based LCD and LED controllers and port exapnders, an SD card and TFT display with SPI interfaces, digital and analog waveform generators, piezo speakers, LED's. 7-Degment LED digits, push-buttons, resistive pull-ups and pull-downs, and slider potentiometers. All devices are accurately modelled electrically (and mechanically).
You can load and edit (and correct) your Arduino program, then run, run-to, halt, step-into, step-over, and step-out-of while watching all accessible program variables and monitoring pin levels (and even pin waveforms, which can also be saved). Simple and clear parse and execution error messages are provided.
UnoArduSim is a free educational tool for everyone to use.
I had developed a number of simulators while working at Queen's University's Department of Electrical and Computer Engineering, and UnoArduSim.exe is my newest one.