![](/img/trans.png)
[英]How to send float data over BLE and display it properly on the UART (nRF Toolbox)
[英]Send Joystick commands over BLE
我正在使用帶有2個74hc165的Adafruit Feather 32u4做操縱桿,以移入我需要的所有17個按鈕。 到目前為止,一切都完成了,但是我對BLE設備還是陌生的,我不知道如何通過藍牙發送數據。 誰能幫我理解?
我正在使用的庫是ArduinoShiftIn和ArduinoJoystickLibrary
這是我的實際代碼:
#include <ShiftIn.h>
#include <Joystick.h>
#include <Arduino.h>
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
ShiftIn<2> shift;
Joystick_ joystick;
void setup() {
Serial.begin(9600);
shift.begin(22, 23, 0, 1 );
joystick.begin();
}
void loop() {
/* analog */
joystick.setXAxis(analogRead(18));
joystick.setYAxis(analogRead(19));
joystick.setRxAxis(analogRead(20));
joystick.setRyAxis(analogRead(21));
/* shift in */
if (shift.update()) {
for (int i = 0; i < shift.getDataWidth(); i++)
joystick.setButton(i, shift.state(i));
}
}
謝謝大家
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.