【Raspberry Pi入门】PWM
好久之前写的了……贴段代码上来好了
稍后上视频。
import RPi.GPIO as GPIO # always needed with RPi.GPIO
from time import sleep# pull in the sleep function from time module
GPIO.setmode(GPIO.BOARD)# choose BCM or BOARD numbering schemes. I use BCM
GPIO.setup(12, GPIO.OUT)# set GPIO 25 as output for white led
white = GPIO.PWM(12, 60) # create object white for PWM on port 25 at 60 Hertz
red.start(0) # start white led on 0 percent duty cycle (off)
# now the fun starts, we'll vary the duty cycle to
# dim/brighten the leds, so one is bright while the other is dim
pause_time = 0.02 # you can change this to slow down/speed up
try:
while True:
for i in range(0,101): # 101 because it stops when it finishes 100
red.ChangeDutyCycle(i)
sleep(pause_time)
for i in range(100,-1,-1): # from 100 to zero in steps of -1
red.ChangeDutyCycle(i)
sleep(pause_time)
except KeyboardInterrupt:
red.stop() # stop the red PWM output
GPIO.cleanup() # clean up GPIO on CTRL+C exit
本论坛的树莓派教程 越来越多 两只树莓派2都出二手了:lol{:5_175:} 凌风清羽 发表于 2016-4-30 23:04
两只树莓派2都出二手了
卖了, 凌风清羽 发表于 2016-4-30 23:04
两只树莓派2都出二手了
有出路吗?我也要卖,换三 hnyzcj 发表于 2016-5-1 07:13
卖了,
是的
,嘿嘿 hnyzcj 发表于 2016-5-1 07:14
有出路吗?我也要卖,换三
你想卖多少软妹币:lol,卖给我,我再卖出去:loveliness: 凌风清羽 发表于 2016-5-1 14:23
你想卖多少软妹币,卖给我,我再卖出去
你多少钱收? hnyzcj 发表于 2016-5-1 20:31
你多少钱收?
你自己找个论坛挂挂或者闲鱼什么的卖掉就好了:lol 凌风清羽 发表于 2016-5-2 00:30
你自己找个论坛挂挂或者闲鱼什么的卖掉就好了
{:5_153:} 树莓派不嫌多啊~
多备着几个可以多做几个项目啊 树莓派积尘中...
页:
[1]