1

I am working on a bluetooth HID device. There are libraries which make HID devices a cake walk if you are making a wired version of your HID device. I managed to configure my bluetooth module to appear as a HID device to the system, it however does nothing yet. I figured if I route the serial data, that my wired version of device is sending to the system on Serial, to Serial1 my bluetooth device will function the same way the wired device worked.

If I am not wrong, code that I came across, maps RX of Serial to TX of Serial1.

Void setup(){ 
    Serial.begin(9600);
    Serial1.begin(9600);
}
void loop(){
     if(Serial.available()){   
      char get= Serial.read();
      Serial1.Write(get);
     }
}

What I want to do is map the TX pin of Serial to TX pin of Serial1 of the pro micro.

9
  • What is your actual question? As I understood, you want to forward the data, that you receive on Serial to the Serial1 interface. That's exactly what your code does (except for the spelling error with the big W in Serial1.Write(get)).
    – chrisl
    Sep 24 '20 at 10:00
  • Re “map the TX pin of Serial to TX pin of Serial1”: you are rather forwarding from Serial’s RX to Serial1’s TX. Sep 24 '20 at 10:00
  • 1
    @chrisl I am using the ArduinoJoystick library by MHeironimus. Whatever communication it does over the Serial connection is done underneath. I went through it's code but couldn't find anything similar to Serial.begin(). It does however use the DynamicHID library which in turn uses the PluggableUSB library. I don't have an electronics background so I couldn't understand much there.
    – REVOLUTION
    Sep 24 '20 at 10:30
  • 1
    Thats because the ArduinoJoystick library does not use Serial. It configures the micro to act as HID-USB device. That is completely different to Serial communication. Thus you cannot just send that over a Serial interface
    – chrisl
    Sep 24 '20 at 10:35
  • 1
    What bluetooth device do you use?
    – chrisl
    Sep 24 '20 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.