In the previous section, we saw how we can access the GPIO pin from Python's interactive shell and change its state. Let's now write a python code and save it as a .py
file and run it like we did at the end of the previous chapter. The python program that is discussed in this section will make an LED blink at an interval of 1 second. The LED will be On for 1 second and Off for another 1 second; this will loop continuously until you break the loop.
The following screenshot shows the program:
The code imports the time module and the Adafruit_BBIO
module just as we did in the interactive shell in the previous section of this chapter and then we set up GPIO_60 as an output pin and then changed the state of the pin to HIGH and LOW in the while loop that runs continuously. We use the time.sleep(1)
function to pause the code for 1 second in between the state changes. The code also has the GPIO.clean()
function that gets executed when a keyboard interrupt...