11609| 32
|
[MP动手做] MicroPython动手做(36)——MixPY之Hello world |
10、多彩PWM呼吸灯 [mw_shl_code=python,false]#MicroPython动手做(36)——MixPY之Hello world #多彩PWM呼吸灯 import time import mixno from machine import Timer from machine import PWM tim_LED_R = Timer(Timer.TIMER0, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_R=PWM(tim_LED_R, freq=500000, duty=100, pin=mixno.pin_D[7]) tim_LED_G = Timer(Timer.TIMER1, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_G=PWM(tim_LED_G, freq=500000, duty=100, pin=mixno.pin_D[6]) tim_LED_B = Timer(Timer.TIMER2, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_B=PWM(tim_LED_B, freq=500000, duty=100, pin=mixno.pin_D[8]) while True: for i in range(0, 100, 1): LED_G.duty(100-i) LED_R.duty(100-i) time.sleep_ms(20) time.sleep_ms(400) for i in range(100, 0, -1): LED_R.duty(100-i) LED_B.duty(100-i) time.sleep_ms(20) time.sleep_ms(400)[/mw_shl_code] |
7、随机变色的LED [mw_shl_code=python,false]#MicroPython动手做(36)——MixPY之Hello world #随机变色的LED import time import random import mixno from machine import Timer from machine import PWM tim_LED_R = Timer(Timer.TIMER0, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_R=PWM(tim_LED_R, freq=500000, duty=100, pin=mixno.pin_D[7]) tim_LED_G = Timer(Timer.TIMER1, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_G=PWM(tim_LED_G, freq=500000, duty=100, pin=mixno.pin_D[6]) tim_LED_B = Timer(Timer.TIMER2, Timer.CHANNEL3, mode=Timer.MODE_PWM) LED_B=PWM(tim_LED_B, freq=500000, duty=100, pin=mixno.pin_D[8]) while True: i = random.randint(0, 100) time.sleep_ms(300) LED_R.duty(100-i) j = random.randint(0, 100) time.sleep_ms(300) LED_G.duty(100-j) k = random.randint(0, 100) time.sleep_ms(300) LED_B.duty(100-k)[/mw_shl_code] |
6、循环RGB灯 [mw_shl_code=python,false]#MicroPython动手做(36)——MixPY之Hello world #循环RGB灯 import time import mixno LED_R=mixno.pin(7,mixno.GPIO.OUT) LED_G=mixno.pin(6,mixno.GPIO.OUT) LED_B=mixno.pin(8,mixno.GPIO.OUT) while True: LED_R.value(0) LED_G.value(1) LED_B.value(1) time.sleep_ms(1000) LED_R.value(1) LED_G.value(0) LED_B.value(1) time.sleep_ms(1000) LED_R.value(1) LED_G.value(1) LED_B.value(0) time.sleep_ms(1000) LED_R.value(0) LED_G.value(0) LED_B.value(1) time.sleep_ms(1000) LED_R.value(0) LED_G.value(1) LED_B.value(0) time.sleep_ms(1000)[/mw_shl_code] |
本帖最后由 驴友花雕 于 2020-6-30 07:00 编辑 主控芯片:K210(64位双核带硬件FPU和卷积加速器的 RISC-V CPU) 显示屏:LCD_2.8寸 320*240分辨率,支持电阻触摸 摄像头:OV2640,200W像素 扬声器:3W单声道喇叭,及2.5mm双声道耳机孔 麦克风:一颗数字高灵敏MEMS硅麦 存储介质:16MBFlash,可外接<32G calss10 TF内存卡 板载功能:RGB三色灯,自定义2颗按键,重力感应 电池管理:PMU电源管理,3重电池保护电路及550mah锂电池 无线网卡:ESP8285,WiFi无线网卡 下载驱动:CH340,USB转TTL串口驱动电路 外接拓展:3个 Type-C扩展接口,可外接18IO口及双电源输出 |
4、点亮板载RGB灯 D6脚接绿色LED D7脚接红色LED D8脚接蓝色LED [mw_shl_code=python,false]#MicroPython动手做(36)——MixPY之Hello world #点亮板载RGB灯(红绿色转换) import time import mixno pin6 = mixno.pin(6, mixno.GPIO.OUT) pin7 = mixno.pin(7, mixno.GPIO.OUT) while True: pin6.value(1) pin7.value(0) time.sleep_ms(1000) pin6.value(0) pin7.value(1) time.sleep_ms(1000)[/mw_shl_code] |
5、变幻彩灯RGB [mw_shl_code=python,false]#MicroPython动手做(36)——MixPY之Hello world #变幻彩灯RGB import time import mixno pin6 = mixno.pin(6, mixno.GPIO.OUT) pin7 = mixno.pin(7, mixno.GPIO.OUT) pin8 = mixno.pin(8, mixno.GPIO.OUT) while True: pin6.value(1) pin7.value(0) pin8.value(0) time.sleep_ms(500) pin6.value(0) pin7.value(1) pin8.value(0) time.sleep_ms(500) pin6.value(0) pin7.value(0) pin8.value(1) time.sleep_ms(500)[/mw_shl_code] |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed