Counter sent back from ESP32 won't stop adding

OK. I have an app which passes a variety of different one character codes to an ESP32 which then runs a WS2128B LED strip. Cahnge colour, change speed, start, stop. All good.
What happens on the strip is that a single light goes from one end of a strip, (60 lights) to the other, and then back again.
When it has done this, (all the way to the right, then all the way to the left), I send a number 1 back to the app.
The problem is, that although only one "1" comes back, once a single pass, (right, then left), has happened, the app starts frantically adding one to the display.

I can't work out how to insert a picture here.

I'm using block

When Clock Timer do
if Bluetoothclient isConnected and
call Bluetoothcoient BytesAbleToReceive > 0
set global_counter to get global_counter + 1
set Counter Text to get global_counter

I know I've isolated the call from the ESP32 back to the app by checking in the Serial Monitor.

Guessing this is pretty obvious.....

I don't see a BlueTooth Receive block in your clock timer loop.

So your input buffer never gets emptied, and your counter keeps going up.

Also, you miss out on whatever content was sent from the other end.

(Canned Reply: ABG - Download those blocks and post them here)

Please download and post each of those event block(s)/procedures here ...
P.S. These blocks can be dragged directly into your Blocks Editor workspace.

See Download Block Images for a demo.


Not sure that worked. Ah, yes. Apparently it did.

All I send from the other end is a 1.
I add that to a counter and display it.

As you say, the 1 seems to repeat and repeat.
You're also right that I don't have a Blue Tooth Receive block.
Do I need one, and if so how do I use it?


Would this work?

Hmm. OK, well, yes, that DOES work.
UNTIL I send something else from the app through BlueTooth, which then seems to get the number count going crazy again.
I'm a bit confused.
Looks like sending something is resetting the BlueTooth client?

That's all I'm sending

So your Clock2 Timer is receiving an unsigned byte, and adding its value to your counter.

You haven't posted your ESP32 code, so we have no way of knowing what might have arrived in that byte.

If all you needed was to have consumed that byte, you could have dropped the incoming byte into a variable just to get it out of the buffer, and add 1 to the counter (assuming you just wanted to blindly count the incoming bytes).