Untuk menghubungkan projek Raspberry Pi kamu dengan dunia luar, kamu perlu belajar:
1. Pengenalan Python
2. GPIO
3. Cara mengimport
4. Komponen elektronika yang akan kamu pasang, contoh: LED, 7 segment display, Sensors: Windspeed sensor, heat sensor (built-in), etc.
Pin GPIO:
3
5
7
8
10
11
12
13
15
16
17
18
19
21
22
23
24
26
Pin Ground
6
9
14
20
25
Pin 5 Volt
2
4
Pin 3.3 Volt
1
17
Pin GPIO bisa berfungsi sebagai
1. Input
Tidak bisa sekedar menghubungkan pin 3 ---> switch ---> ground. Karena akan float.
2. Output
Pin 3 --> LED ---> Resistor ---> Ground / pin 6
Steps:
In python script
1. Import GPIO module
2. Set the board mode to that of your preference
3. Set up the pins you want to use, and
4. Turn them on
Contoh:
1. Pengenalan Python
2. GPIO
3. Cara mengimport
4. Komponen elektronika yang akan kamu pasang, contoh: LED, 7 segment display, Sensors: Windspeed sensor, heat sensor (built-in), etc.
Pin GPIO:
3
5
7
8
10
11
12
13
15
16
17
18
19
21
22
23
24
26
Pin Ground
6
9
14
20
25
Pin 5 Volt
2
4
Pin 3.3 Volt
1
17
Pin GPIO bisa berfungsi sebagai
1. Input
Tidak bisa sekedar menghubungkan pin 3 ---> switch ---> ground. Karena akan float.
2. Output
Pin 3 --> LED ---> Resistor ---> Ground / pin 6
Steps:
In python script
1. Import GPIO module
2. Set the board mode to that of your preference
3. Set up the pins you want to use, and
4. Turn them on
Contoh:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) # set board mode to Broadcom
GPIO.setup(17, GPIO.OUT) # set up pin 17
GPIO.setup(18, GPIO.OUT) # set up pin 18
GPIO.output(17, 1) # turn on pin 17
GPIO.output(18, 1) # turn on pin 18
No comments:
Post a Comment