adds debug logging, fixes pin modes and control pin numbering