2018-03-1220:14:00 import pyb import time from pyb import Pin xlights = (pyb.LED(2),pyb.LED(3)) MO = Pin('X1',Pin.OUT_PP) accel = pyb.Accel() i = 0.0001 while True: x = accel.x() print("x=") print(x) # 获取到陀螺仪x数据 Y = x+20 MO.high() time.sleep(i*Y
Arduino的另外几种模块,我们常见的joystick摇杆模块. 用起来很爽,摇杆 有X,Y轴可调 这里有一篇非常想尽的示例代码: http://www.geek-workshop.com/forum.php?mod=viewthread&tid=96 什么也不操作的话,显示的数字是512 const int xside = A0; const int yside = A1; ; ; void setup() { // set the serial port Serial.begin(); }