Receiving discrete data from Arduino (bluetooth)

Hi all, I’m making an Ardiuno app with bluetooth. I’ve been watching tutorials (most about App Inventor, but same thing) and everything is going very well. However all the tutorials show how to receive continuous sensor data from the Arduino using the “clock”.

I’m not interested in receiving continuous data. My Arduino code performs certain actions at certain times, and the app needs to change in sync with these actions. For example, if a servo motor moves I need to trigger a timer on the app. Or if a sensor is triggered at any random point I need the app to make a sound.

At the moment I’m using a Clock block and it’s not going well. I have the clock timer interval set to 10 ms, but sometimes it catches the data and sometimes it doesn’t. Setting the interval to 1 ms doesn’t working at all (assuming this is too high a sample rate?)

The clock just seems unnecessary. Is there a way for the app to always be open to receiving new bluetooth data, rather than at specific clock intervals?

Thank you so much for your help!!

The attached picture is a small portion of the relevant code. I have initialized all the other global vars elsewhere.!

Bluetooth receive|690x490

1 Like

Your code seems correct… Could you show the blocks that help you to connect to arduino? Also try to see whether the arduino is sending signals