In this section, we will ensure that the library is correctly installed and add the user to the group. This will enable the user to use the GPIO pins without having root privileges. This will be followed by the section on getting started with GPIO control programming in Python.
In order to get started with programming in the Raspberry Pi, we will launch Python IDLE3 from the desktop.
from time import sleep from quick2wire.gpio import pins, Out with pins.pin(7, direction=Out) as out_pin: while True: out_pin.value = 1 sleep(1) out_pin.value = 0 sleep(1) out_pin.unexport()
sleep
class from the time
module in the first line. This is required to introduce a 1-second delay between turning the LED on and off every other second:from time import sleep
quick2wire
GPIO library:from quick2wire.gpio import Pin
LED_output = Pin(8, Pin.Out)
LED_output=1
LED_output=0
while
loop:while True: LED_output=1 sleep(1) LED_output=0 sleep(1)
while
loop. Hence, the code that is at a different indent is executed infinitely.out_pin.unexport()
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setup(8,GPIO.OUT) GPIO.output(8,GPIO.LOW) while True: GPIO.output(8,GPIO.HIGH) sleep(1) GPIO.output(8,GPIO.LOW) sleep(1) GPIO.cleanup()
GPIO.setmode(GPIO.BCM) GPIO.setup(8,GPIO.OUT)
GPIO.output(8,GPIO.HIGH)
GPIO.output(8,GPIO.LOW)
while True: GPIO.output(8,GPIO.HIGH) sleep(1) GPIO.output(8,GPIO.LOW) sleep(1)
GPIO.cleanup()
18.119.120.159