To trail and error with Arduino sketchs you will need some tools, one of them is an oscilloscope, lets learn the basics of this important tool.
An oscilloscope is a debugging tool for electronics circuits where you can prob any point and check out the signal in watch it in real time (voltage over time)
for example you could check an Arduino PWM signal with this tool and measure the duty cycle, voltage or if it is even working at all.
I bought mine here
This is a starting level device and it has it's limitation but it is cheap and will do the job.
It does not have it's own display like and expensive, portable and professional ones, but it will rather connect to your computer via USB and you will see the signal over the computers screen when lunching the application that comes with it.
Please check out this video to see it in action
Also note that you can use the scope with the software provided or use
the open source PulseView or the another great alternative is basicscope