GPIO Zero Cheatsheet
GPIO Zero Cheatsheet
raspberrypi.org/resources
LED
led.on()
GND
led.off()
led.toggle()
GP17
led.blink()
a b c d e
USB X2
g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
21
22
23
24
25
3
4
5
GND
GP4
Motor
GPIO
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
21
22
23
24
25
a b c d e
g h i
led.on()
1
2
GP2
GP3
led.color = (r, g, b)
led.red = 1
motor.forward()
led.off()
USB X2
motor.backward()
motor.stop()
motor.reverse()
Button
+
a b c d e
1
2
3
4
5
GND
GP4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
21
22
23
24
25
from
import Button
_
+gpiozero
j
button
= Button(4)
1
2
while
True:
3
4if button.is_pressed:
5
6
print("Button is pressed")
7
8else:
9
print("Button is not pressed")
10
g h i
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
21
22
23
24
25
USB5V X2
GND
GP4
a b c d e
button.wait_for_press()
button.wait_for_release()
button.is_pressed
button.when_pressed = led.on
button.when_released = led.off
pir.wait_for_motion()
pir.wait_for_no_motion()
pir.motion_detected
pir.when_motion = motor.forward
pir.when_no_motion = motor.backward