Bluetooth Module(HC-05) SENDING data/bytes to the APP to detect

I can't seem to know how to build it. Basically, I'm planning to have arduino send something such as certain value or bytes, it'll be a loop which checks if...

Let's say:
BT module sends A = 1 or 0 to the app. Now app that has a while loop which checks

while (true) {

if BT sends A = 1 {
Title:OPEN visibility = true
Title:CLOSED visibility = false
break loop
}
else if BT sends A = 0 {
Title:CLOSED visibility = true
Title:OPEN visibility = false
break loop
}
Print: Error, either BT failed to send or A is neither 1 or 0.
}

I'm having a difficult understanding on bluetooth and I just don't know if it's possible on MIT App Inventor. Please help, I appreciate all the help.

Here is one of @ABG's examples
In App Inventor you use a Clock component and its Timer event to check for something endlessly
Taifun

Here is a simple BlueTooth text receiver sample, for single value per line:
blocks
initialize global message to


See also

Taifun

1 Like

I'm sorry if I'm asking too much. I'm still not home and I didn't bring my build so if you have time, can I get confirmation if what I did is correct? Also thank you for your help!

I might be asking at the wrong site, but is this code in arduino is good? I tried making it shorter but I can't:

while (BTComm.available()) {
if (c <= 10) {
BTSerial.println("A=1");
break;
}
else if (c = 90) {
BTSerial.println("A=0");
break;
}

}

Replace the second Bluetooth Read block with a reference to the variable that received the previous Bluetooth Read results.

Here is a simple BlueTooth text receiver sample, for single value per line:
blocks
initialize global message to


1 Like

Oh, I just need to confirm the message received like this?:

Thank you very much! I'll try this in a few days after I'm done. Sorry for the inconvenience.

That looks like it should work.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.