'''
STM32F4DISC开发板引脚映射关系
1=red(PD14), 2=green(PD12), 3=yellow(PD13), 4=blue(PD15)
LED_GREEN PD12
LED_ORANGE PD13
LED_RED PD14
LED_BLUE PD15
# LEDs 3 and 4 support PWM intensity (0-255)
'''
from pyb import LED
import time # 调用sleep sleep_ms sleep_us延时函数
led3_pwm = LED(3) # PD13
led4_pwm = LED(4) # PD15
print('Hello World')
if __name__ == '__main__':
while True:
for i in range(0,255,5): # 0 - 254 步长5
led3_pwm.intensity(i)
led4_pwm.intensity(255-i)
time.sleep_ms(50)
# print('value1=%d' % led3_pwm.intensity())
# print('value2=%d' % led4_pwm.intensity())
print('i= {0} ,led3_value={1},led4_value={2}' .format(i,led3_pwm.intensity(),led4_pwm.intensity()))
else:
print("Finally finished!")
|