#include <Wire.h> #include <MPU6050.h> #include <HID-Project.h>

MPU6050 mpu;

void setup() { Serial.begin(9600); Wire.begin(); mpu.initialize(); mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_2); mpu.setFullScaleGyroRange(MPU6050_GYRO_FS_250); Keyboard.begin(); }

void loop() { int16_t ax, ay, az;

mpu.getAcceleration(&ax, &ay, &az);

Serial.print("Accelerometer: "); Serial.print(ax); Serial.print(", "); Serial.print(ay); Serial.print(", "); Serial.println(az);

if (ax >= 1000) { Keyboard.press('A'); delay(100); Keyboard.release('A'); }

delay(100); }


原文地址: https://www.cveoy.top/t/topic/pOnm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录