Help with adding extra functionality to code

Hey I’ve recently flashed a CC2541 Bluetooth chip with a HID firmware and am wondering if any one can help with adding extra keys to this code? The device as it stands at the moment is acting as a keyboard and pulling pin 3 to ground sends the Winkey, (0xE3) to my connected android device.
Ive hit a wall because coding is my weak point, great technical skills but feel completely held back by my programming understanding, hahaha.
well, cheers in advance!

#define hutLeftGUI 0xE3
#define BT Serial1

void cmd(const char * s, int timeout=100, bool bSendCR=true) {
  Serial.write("> ");

  if (bSendCR) {

  // serial output is tricky, let's use read timeout for now
  long t = millis();
  while(millis() < t + timeout) {
    while (BT.available()) {

void keyCommand(uint8_t modifiers, uint8_t key1, uint8_t key2 = 0, uint8_t key3 = 0, uint8_t key4 = 0, uint8_t key5 = 0, uint8_t key6 = 0) {
  char buf[16];
  sprintf(buf, "%s%c", modifiers==0x80 ? "KD" : "KU", key1);  

void setup() {  
  Serial.begin(115200); // This pipes to the serial monitor  
  BT.begin(57600); // This is the UART, attached to HM-10   
  pinMode(3, INPUT); // input mode for the button pin (D3)
  digitalWrite(3, HIGH); // set button pin to HIGH (software pullup) so it triggers when pulled to GND

bool wasPressed = false;
void loop() {
  int keyCode = hutLeftGUI;  // winkey
  bool pressed = digitalRead(3)==LOW;
  if (pressed != wasPressed) {
    keyCommand(pressed ? 0x80 : keyCode, keyCode);
    wasPressed = pressed;

Hey I've recently flashed a CC2541 Bluetooth chip with a HID firmware

Is that something you can do with the Arduino IDE?

Or are you using some Arduino board in conjunction with the Bluetooth device?


No, I'm using the modified CC2541 with an uno.

No, I'm using the modified CC2541 with an uno.

Please tell us what the code in the Uno is intended to do and what it actually does.

And post the complete Uno program.

SoftwareSerial is unlikely to work reliably at a baud rate above 38400, and lower may be better.