树莓派RGB三色LED灯驱动

作者:吴业亮
博客:wuyeliang.blog.csdn.net

管脚针脚
负极39号针脚
RGPIO35,37号
GGPIO19,35号
BGPIO13,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灯

    原文作者:Yeliang Wu
    原文地址: https://blog.csdn.net/wylfengyujiancheng/article/details/118369298
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞