Receive BLE data from Arduino

Hello

I want to build a remote control for my smartphone.
As Arduino I have a https://www.dfrobot.com/product-1259.html

Unfortunately the <ArduinoBLE.h> is not supported on this device.

I want to send only the numbers 1-4 to my MIT app.

Unfortunately I can only send to the Arduino but not receive on the app.

Unfortunately, no data arrives in the app.
I have also tried to change the data type.

Can someone give me a tip?


BLETest.aia (190.6 KB)

Arduino Code:

int inPin1 = 2;

int inPin2 = 3;
int inPin3 = 4;
int inPin4 = 5;
int button = 0;

void setup() {
Serial.begin(9600);

pinMode(inPin1, INPUT_PULLUP);
pinMode(inPin2, INPUT_PULLUP);
pinMode(inPin3, INPUT_PULLUP);
pinMode(inPin4, INPUT_PULLUP);
}

void loop() {
button = 0;

if (digitalRead(inPin1) == LOW) {
button = 2;
}
if (digitalRead(inPin2) == LOW) {
button = 1;
}
if (digitalRead(inPin3) == LOW) {
button = 4;
}
if (digitalRead(inPin4) == LOW) {
button = 3;
}
if (button > 0) {

Serial.println(button);
delay(1000);

}

}

In your App Inventor code you need to add:

otherwise your StringsReceived block will never receive anything.

Be aware that the stringValues returned may be a list.

An excellent resource is: http://www.martyncurrey.com/arduino-hm-10-and-app-inventor-2/

Hope this helps.
Simon

1 Like