作者:吴业亮
博客:wuyeliang.blog.csdn.net
管脚 | 针脚 |
---|---|
负极 | 39号针脚 |
R | GPIO35,37号 |
G | GPIO19,35号 |
B | GPIO13,33号 |
代码
#! /usr/bin/env python3
# -*- coding:UTF-8 -*-
# LED Pi
# GND ------------------ GND
# R ------------------ Pin 37
# G ------------------ pin 35
# B ------------------ pin 33
#
#---------------------------------------------------
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
RGlist = [33,35,37]
GPIO.setup(RGlist,GPIO.OUT)
if __name__ == '__main__':
try:
while True:
for i in RGlist:
GPIO.output(i,1)
time.sleep(0.5)
GPIO.output(i,0)
except KeyboardInterrupt:
GPIO.cleanup()
实现效果
树莓派RGB灯