Hardware Reference
In-Depth Information
GPIO.output(8,GPIO.LOW)
while True:
GPIO.output(8,GPIO.HIGH)
sleep(1)
GPIO.output(8,GPIO.LOW)
sleep(1)
GPIO.cleanup()
2. Ater imporing the required modules, we get started with seing up the pin
numbering mode. There are two types of pin numbering modes, namely:
The BCM Pin numbering mode : The pin numbers are based upon the pin
numbers of the BCM chip.
The Board numbering mode : The pin numbers are based upon the pin
numbers of the Raspberry Pi GPIO header.
In this example, we will set the BCM numbering mode and set pin 8 as
the output:
GPIO.setmode(GPIO.BCM)
GPIO.setup(8,GPIO.OUT)
3. We can set the pin to logical high (3.3 V) as follows:
GPIO.output(8,GPIO.HIGH)
4. We can set the pin to logical low (3.3 V) as follows:
GPIO.output(8,GPIO.LOW)
5.
Now, the LED can be made to blink with a 1 second delay:
while True:
GPIO.output(8,GPIO.HIGH)
sleep(1)
GPIO.output(8,GPIO.LOW)
sleep(1)
6. When the program is interrupted by typing CTRL + C , we have to clean up and
release any occupied GPIO resources:
GPIO.cleanup()
Objective complete - mini debriefing
In this secion, we inished wriing a program to make an LED blink. In the next secion, we
will put a circuit together that makes an LED blink.
 
Search WWH ::




Custom Search