Adruino101Pins app closing when calling function

Hi, Trying to do some basics on/off with Arduino101Pins but my app closes down when calling function WritePinState(1)
Am I missing some basic here?
Adruino is loaded with AIM-for-Things-Arduino101


Arduino101LED (1).aia (247.1 KB)

Hi Teddy

That's no doubt because the connection to the device has not been made beforehand. You cannot have "connect to device" in the same event as "Start Scanning". That can only be done after the scan is complete, which your other code blocks seem to understand :thinking:

Tried to remove 'ConnectToDeciveWithServiceAndName' but with the same result.
I am getting a 'Status: Connected'
If I change from 'Arduino101Pins' to 'Arduino101Led' it works?
In 'AIM-for...' I'm using:
#define LED ENABLED
#define PINS ENABLED
#define RGBLCD ENABLED

If you've previously connected the BLE device with PINS set to DISABLED, then the OS will have cached the service list based on that. You may need to turn your Bluetooth off and on again to potentially clear this.

did a power-cycle on the smartphone and Adruino and the results are equal?

Appreciate all your help!

Uploaded a working setup for LED but alt the same time a call to Pins will crash the app.
Arduino101LED (2).aia (247.1 KB)

App.