Next, we define several global variables. For now, review the following comments for their purposes. You'll see them being used as we progress through the code:
LED_GPIO_PIN = 21 # LED GPIO Pin
THING_NAME_FILE = 'thing_name.txt' # Thing name file
URL = 'https://dweet.io' # Dweet.io service API
last_led_state = None # "on", "off", "blinking"
thing_name = None # Thing name
led = None # GPIOZero LED instance
As you read through the master source file, following these variable definitions, you'll also notice that we are using the Python logging system instead of print() statements:
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger('main') # Logger for this module
logger.setLevel(logging.INFO) # Debugging for this file. # (2)
If you need to turn on debugging for the program to diagnose a problem or to see...