首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法通过蓝牙把这个Keyboard.Press();命令无线发送到我的电脑上?

有没有办法通过蓝牙把这个Keyboard.Press();命令无线发送到我的电脑上?
EN

Stack Overflow用户
提问于 2015-11-27 10:49:46
回答 1查看 532关注 0票数 1

我已经能够通过蓝牙实现我的Arduino微型板的无线数据发送。我使用以下代码将传感器数据从arduino板发送到PC。但我希望它能够执行Keyboard.Press();根据我从连接到微型板的传感器获得的数据。

有没有办法通过蓝牙把这个Keyboard.Press();命令无线发送到我的电脑上?

我使用带有HC-05的Arduino Micro向PC无线发送数据。

代码语言:javascript
复制
#include <SoftwareSerial.h>
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU9250.h"

MPU9250 accelgyro;
I2Cdev   I2C_M;

int16_t ax, ay, az;
int16_t gx, gy, gz;
int16_t mx, my, mz;
float Axyz[3];

const int rxPort = 8; // connected to Bluetooth TX
const int txPort = 9; // connected to Bluetooth RX
SoftwareSerial myConnection = SoftwareSerial(rxPort, txPort);

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Initializing I2C devices...");
  accelgyro.initialize();
  Serial.println("Testing device connections...");
  Serial.println(accelgyro.testConnection() ? "MPU9250 connection successful" : "MPU9250 connection failed");
  delay(1000);
  myConnection.begin(9600);

}

void loop() 
{
  myConnection.print(mapX);
  myConnection.print("  ,  ");
  myConnection.println(mapY);
  ////Keyboard.press('a');
}
EN

回答 1

Stack Overflow用户

发布于 2015-11-27 17:43:47

对于蓝牙v2,您需要一个支持HID的蓝牙模块。当我知道这个产品的时候

https://www.sparkfun.com/products/retired/10938

但现在它已经退役了。

如果你想转到蓝牙v4,我不知道。在网上搜索,你似乎需要实现"HID over GATT profile“(HOGP)。

我找到了一些普通芯片(nRF8001,nRF2740/nRF2741)的this library,它有蓝牙键盘的例子;否则,如果你已经有一块BT4板,试着寻找实现该配置文件的库,或者试着将它移植到你的平台上。

当然,这只适用于蓝牙4板,因为蓝牙2有一些固定的“类”(所以你不能把BT-串行适配器变成BT-HID设备)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33949604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档