Error 507 hc 05 bluetooth module continuation

Relating to 0_1, I changed to internall pull up resistor, it works fine I guess. I hope I would not jinx myself :smiley:

Yep!
But don't forget the possibility to add the debouncing function. Since you have a micro-switch and not a simple pushbutton, a bouncing (even lasting a few milliseconds) can mislead the digital.reading.

Another debouncing procedure that can be easily implemented is to read 3 times consecutively the microswitch. If the readings are the same (always 0 or always 1) for the three times, you cansider it stable (at 0 or at 1) then you set the new reading as = 0 or =1 accordingly. After the step above, if the new reading is different with respect to the old one, you set the change (as in the current code).

What value should I asign to debounceDelay, 50ms?

image

try to follow this hint (code and comment :smirk:)

Hey, this is part of the code I modified for debouncing:



It does not show anything on serial monitor when I removed BT part and the app does not show any difference, I assume it is the code I wrote that is somehow wrong...

PS: (about the exact same app that did not work), wow they really are right when they say if it does not work, turn it off and on again, new app works now!

Yep, hardware reset sometimes helps :rofl: :rofl: :rofl:
(...let me check the debounce code....)

I realized the problem arises after I try to put the image on the layout where the list picker is, after I put the image there are no devices shown

uskiara ou Bruno vcs sabem como fazer para usar o bluetooth em várias telas sem ter q desconectar e na outra tela ter que conectar novamente

The answer remains the same:

Nesse link achei apenas utilização do notificador em várias telas não o bluetooth

OK, let's do it different.
do the following changes:
move the NewInput variable as global


Add this function:

Modify the loop as per image below:

.

The rationale of the debounce (extra simple !) is in the comments.
Hope it works for you.

Don't wanna jinx myself but it works perfectly, thanks!

1 Like

Dear @UserName123,
first of all, please open a new topic, since this one is not related to the use of multiple screen and BT.
Moreover, what @Ramon has already said, the BT cannot work with a multiple screen structure (it disconnects every time you pass from one screen to another).
The solution is to use the virtual screens instead (i.e. by using Horizontala and Verstical arrangements making them visible/hidden as they were different screens)
For sake of easy-finding you can take the annexed .aia as an example.
MultipleScreen.aia (849.0 KB)
Anyway, many more topics can be found on this matter in the community.
.

I don't know how to describe it but its like the app needs time to adapt so it can change those ones and zeros correctly. Yesterday after you wrote the code I tried it and everything worked perfectly, now I do it and after few repeated changes it just randomly starts changing those ones and zeros. Is it normal since I clicked microswitch to often and after some time states get mixed? I mean, should I ignore it since I won't need it to change it fast(it will be kept clicked unless door opens)

Dear Bruno,
the debounce "filter" that I gave you is just a "poor" filter.
More complex ones can be written, for sure, and I believe that you'll find them on the web (i.e. on Arduino forums).
A microswitch, like relays, can have a stabilisation time that lasts up to 2 or 3 hundreths of milliseconds. In other words, within that time window the signal can have glitches, that can lead to a wrong status evaluation. To have a more robust solution you can add a HW filter, an RC net for example. One "free of charge" step is to use the INPUT_PULLUP feature of the input port (but, as far as I remember, you already use that feature, aren't you ?)
If your real use is to acquire the status of a door, you can do in a completely different way: after the input has changed, you wait seconds before reading it again. If the two readings have the same value (HIGH+HIGH or LOW+LOW) you can reasonably assume that the true value is what you have read both. If the values differ, you shall throw them away and do nothing. This is because the bouncing, if any, will be surely ended after a couple of seconds.
Obviously this assumes that you can wait 2 seconds before deciding if the door has been opened or closed.

Yes, I use internal pull up. Well I think 2 seconds my be to lomg, especially since I have a dog which can utilize those 2 seconds of advantage​:grin::rofl:

I have a question about the global variable(can I have 2 of them and define what input data is stored to the first and what to the second.

OK, I agree, 2 seconds could be too much for your dog... :rofl:
So, you can try to find a better solution (a smarter filter, based on some hundreths of milliseconds instead).
To this purpose you'd better dig the Arduino forum: for example I found rich of solutions the following link

Give it a sight.

Thanks for providing me with a link. I will dig into it and try it out. About the global variable part, can I use 2 of them in MIT app inventor and define what received data each of them should store, if you get me?