電子工作でLEDの明るさを調整してみた【ラズパイ】サンプルコード
code:Python
import RPi.GPIO as GPIO
import time
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT) #赤線 GPIO.setup(17, GPIO.OUT) #黄色線 while True:
count = 0
while count < 1000:
GPIO.output(4, GPIO.HIGH)
time.sleep(0.01)
GPIO.output(4, GPIO.LOW)
time.sleep(0.01)
while True:
count = 0
while count < 1000:
GPIO.output(17, GPIO.HIGH)
time.sleep(0.01)
GPIO.output(17, GPIO.LOW)
time.sleep(0.07)
count += 1