This post was last edited by Feiyangzizi on 2018-6-19 20:11 I. Preface I have introduced how to configure Tera Term VT [/url]
before. Next, let's do a simple experiment. I watched the Internet and tested the LED. I suddenly found that I could use the six axes on the board to collect data. When swinging, I called intensity to dim the LED. The larger the swing, the larger the absolute value of the output data. In this way, the larger the PWM modulation value, the brighter the LED (4). Second, vibration detection controls LED brightness In pyb, there are multiple library functions that can be called directly. Enter help() in Tera Term TV, and many functions that can be called will pop up
This time, we use the three functions pyb.LED(), pyb.Accel(), and pyb.delay(). First, define led=pyb.LED(4) to specify the special LED4 light, which can adjust the brightness. Then define a PWM=0, variable definition and assignment. Then, in the while loop, read the X, Y, and Z values of the three-axis sensor continuously and add them to get the PWM value. Finally, modulate the LED4 light, which will make the change in any aspect of the three-axis sensor change the LED light.
The video will be updated later and is still under review. . . . . . - >>> led=pyb.LED(4) >>> acc=pyb.Accel() >>> pwm=0 >>> while True: ... pwm=(acc.x()+acc.y()+acc.z())%255 ... led.intensity(pwm) ... print(acc.x(),acc.y(),acc.z()) ... pyb.delay(100) ... ...
复制代码 Three, Postscript I feel that PyboardCN2 is quite fun to use. You can use the existing resources to configure a variety of combinations, and you can debug directly without the trouble of compiling and burning. . This content is originally created by EEWORLD forum user Fei Yang Zi Ji. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source