Skip to content

bluetooth connecting trouble with Mac  #7

Open
@lolololololololololololololololo

Description

so, first of all, I really enjoyed working with the library, it makes everything very clear end easy. but I have a problem when I try to connect to my MacBook Pro (Retina 13 inch, early 2015).
it just keeps on loading and then after a few seconds just stops.
Somehow it got it to connect once ore twice but only those times.
But when I try to connect it to my iPhone (iPhone 7 ) it works like a charm.
I am using this board:
https://www.joy-it.net/de/products/SBC-NodeMCU-ESP32

her is the code I wrote:
`#include <BleKeyboard.h>

BleKeyboard bleKeyboard("esp 32 Macro", "lolo", 100);
const int buttonPin0 = 2;
const int buttonPin1 = 4;
const int buttonPin2 = 18;
const int buttonPin3 = 19;
const int buttonPin4 = 21;

int buttonState0 = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;

int lastButtonState0 = LOW;
int lastButtonState1 = LOW;
int lastButtonState2 = LOW;
int lastButtonState3 = LOW;
int lastButtonState4 = LOW;

unsigned long lastDebounceTime0 = 0;
unsigned long debounceDelay0 = 50;

unsigned long lastDebounceTime1 = 0;
unsigned long debounceDelay1 = 50;

unsigned long lastDebounceTime2 = 0;
unsigned long debounceDelay2 = 50;

unsigned long lastDebounceTime3 = 0;
unsigned long debounceDelay3 = 50;

unsigned long lastDebounceTime4 = 0;
unsigned long debounceDelay4 = 50;

void setup() {

Serial.begin(115200);
Serial.println("Starting BLE work!");
bleKeyboard.begin();

pinMode(buttonPin0, INPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);

}

void loop() {

int reading0 = digitalRead(buttonPin0);
int reading1 = digitalRead(buttonPin1);
int reading2 = digitalRead(buttonPin2);
int reading3 = digitalRead(buttonPin3);
int reading4 = digitalRead(buttonPin4);

if(bleKeyboard.isConnected()) {

if (reading0 != lastButtonState0) {

lastDebounceTime0 = millis();

}

if (reading1 != lastButtonState1) {

lastDebounceTime1 = millis();

}

if (reading2 != lastButtonState2) {

lastDebounceTime2 = millis();

}

if (reading3 != lastButtonState3) {

lastDebounceTime3 = millis();

}

if (reading4 != lastButtonState4) {

lastDebounceTime4 = millis();

}

if ((millis() - lastDebounceTime0) > debounceDelay0) {

if (reading0 != buttonState0) {
  buttonState0 = reading0;

 
  if (buttonState0 == HIGH) {
    bleKeyboard.print("2 ");
    
    Serial.println("0");
  }
}

}

if ((millis() - lastDebounceTime1) > debounceDelay1) {

if (reading1 != buttonState1) {
  buttonState1 = reading1;

 
  if (buttonState1 == HIGH) {
    bleKeyboard.print("4 ");
    Serial.println("1");
  }
}

}

if ((millis() - lastDebounceTime2) > debounceDelay2) {

if (reading2 != buttonState2) {
  buttonState2 = reading2;

 
  if (buttonState2 == HIGH) {
    bleKeyboard.write(KEY_LEFT_GUI);
    bleKeyboard.print("z");
    Serial.println("2");
  }
}

}

if ((millis() - lastDebounceTime3) > debounceDelay3) {

if (reading3 != buttonState3) {
  buttonState3 = reading3;

 
  if (buttonState3 == HIGH) {
    bleKeyboard.print("19 ");
    Serial.println("3");
  }
}

}

if ((millis() - lastDebounceTime4) > debounceDelay4) {

if (reading4 != buttonState4) {
  buttonState4 = reading4;

 
  if (buttonState4 == HIGH) {
    bleKeyboard.print("21 ");
    Serial.println("4");
  }
}

}

lastButtonState0 = reading0;
lastButtonState1 = reading1;
lastButtonState2 = reading2;
lastButtonState3 = reading3;
lastButtonState4 = reading4;
}
}`
maby someone can help me. I would realy appreciate it
best reguards Lorenz

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions