Unyil Raspi #13 Menyalakan 8 Led Secara Bergantian

Anggy ingin sharing tentang cara menyalakan 8 led bisa nyala secara bergantian

siapkan :
1 (satu) Menggunakan Raspberry Pi 3

2. 8 (Delapan) LED

3. 1 (satu)  breadboard

4. kabel Jumper secukupnya

5. Adaptor 2A

yuk cek this out :

Laptop dan Raspberry Pi harus terkoneksi pada Jaringan yang Sama

Rangkai Led pada Pin GPIO Raspberry Pi dan buka terminal raspi
dan kodingan nya

import RPi.GPIO as GPIO
 import time

GPIO.setmode(GPIO.BCM)
 GPIO.setup(25,GPIO.OUT)
 GPIO.setup(14,GPIO.OUT)
 GPIO.setup(21,GPIO.OUT)
 GPIO.setup(12,GPIO.OUT)
 GPIO.setup(26,GPIO.OUT)
 GPIO.setup(19,GPIO.OUT)
 GPIO.setup(13GPIO.OUT)
 GPIO.setup(6,GPIO.OUT)

while True:

GPIO.output(25, GPIO.HIGH)
 time.sleep(1)

GPIO.output(25, GPIO.LOW)
 time.sleep(1)

GPIO.output(14, GPIO.HIGH)
 time.sleep(1)

GPIO.output(14, GPIO.LOW)
 time.sleep(1)

GPIO.output(21, GPIO.HIGH)
 time.sleep(1)

GPIO.output(21, GPIO.LOW)
 time.sleep(1)

GPIO.output(12, GPIO.HIGH)
 time.sleep(1)

GPIO.output(12, GPIO.LOW)
 time.sleep(1)

GPIO.output(26, GPIO.HIGH)
 time.sleep(1)

GPIO.output(26, GPIO.LOW)
 time.sleep(1)

GPIO.output(19, GPIO.HIGH)
 time.sleep(1)

GPIO.output(19, GPIO.LOW)
 time.sleep(1)

GPIO.output(13, GPIO.HIGH)
 time.sleep(1)

GPIO.output(13, GPIO.LOW)
 time.sleep(1)

GPIO.output(6, GPIO.HIGH)
 time.sleep(1)

GPIO.output(6, GPIO.LOW)
 time.sleep(1)

 

3. lalu jalankan sudo python light6.py

4. dan lampu pun akan menyala ^^

 

back to Unyil Raspi #12
next to Unyil Raspi #14

79 Total Views 1 Views Today
Views All Time
Views All Time
71
Views Today
Views Today
1

7 Responses

Leave a Reply

You must be logged in to post a comment.