Update dscratchgpio3.py

Start of main code refactoring to make it prettier and more pythonic