【问题标题】:How to blink the red colour of RGB led如何让RGB LED的红色闪烁
【发布时间】:2019-06-27 13:49:34
【问题描述】:

这是我的 raspberry-pi RGB 闪烁的代码详细信息

蓝色和绿色闪烁但红色不工作我也尝试交换gpio pin但我得到相同的结果

import RPi.GPIO as GPIO
red_pin = 18
green_pin = 23
blue_pin = 24
GPIO.setmode(GPIO.BOARD)
GPIO.setup(red_pin, GPIO.OUT)
GPIO.setup(green_pin, GPIO.OUT)
GPIO.setup(blue_pin, GPIO.OUT)
GPIO.setwarnings(False)
GPIO.output(red_pin, False)
GPIO.output(green_pin, False)
GPIO.output(blue_pin, False)
try:         
   while True:
       UserInput = input()
       UserInput = str(User)
       if UserInput == "red":
            GPIO.output(red_pin, True)
            GPIO.output(green_pin, False)
            GPIO.output(blue_pin, False)
       elif UserInput == "green":
            GPIO.output(red_pin, False)
            GPIO.output(green_pin, True)
            GPIO.output(blue_pin, False)
       elif UserInput == "blue":
            GPIO.output(red_pin, False)
            GPIO.output(green_pin, False)
            GPIO.output(blue_pin, True)
       else:
           print("Only red, green, and blue are valid colors.")
finally:  
  print("Cleaning up.")
  GPIO.cleanup()

【问题讨论】:

  • 您有其他可以尝试的红色 LED 灯吗?也许是为了确保它也不是被破坏的 LED 本身

标签: python-3.x raspberry-pi3


【解决方案1】:

解决方案非常简单,真的。尝试另一个 LED - 你有,这似乎工作。

你在用电阻吗? 因为我只能收集到你已经设法吹灭了 RGB LED 的红色部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多