First of all, I want to thank the community for the previous help I received in implementing the decoding part of my project. Thanks to that, the decoding process is now working perfectly.
Now, I need assistance with a different part of the project. I am trying to format a binary string so that every 8 bits are grouped and separated by a space.
Explanation: Given a binString of length n (at the final project, it will recieve sequences of bits every time it is working), I want to:
Insert a space every 8 bits to keep the structure intact.
Ensure that no segmentation errors occur.
Handle cases where the string length is not a multiple of 8.
What I Need Help With
Sequence received
"111111110100110101100001011100110110100101101110110011"
Title: Help Needed – Bit Shifting Not Working as Expected in Loop
Hello everyone,
Thanks again for the help I previously received — the decoding part of my project works perfectly. Now, I’ve run into a new issue.
What I'm Trying to Do:
I want to create a system that continuously shifts a binary string by:
Removing the first bit (from the left),
Adding a new bit to the end (on the right),
Keeping the string structured in 8-bit blocks separated by spaces,
Repeating this process automatically in a loop, not manually.
Currently, I'm using a button to do this bit-shifting step-by-step, but the behavior becomes unpredictable after the first few presses — it works for one iteration, then starts failing or giving inconsistent formatting. In all iterations, the decoding returns "not found", even when the right sequence is supposed to be there.
My Current Situation:
Here’s an example of what’s happening step-by-step after each button press:
Despite the correct sequence being in the string, the decoder fails to find it, returning "not found" every time.
What I'm Asking For Help With:
How can I reliably implement a bit-shift mechanism in MIT App Inventor, where:
The first bit is removed,
A new bit is added to the end,
The string is reformatted every time into 8-bit blocks with spaces,
The loop works continuously or smoothly (not just per button press)?
How can I avoid the formatting errors that cause the decoder to miss the actual data?
I’m attaching the blocks I’m using for this logic, and would really appreciate any suggestions to improve the implementation or restructure the logic better for this bit-shifting system.
No no no, it's more easy. We are just deleting the first number on the left and we are shifting every bit one position to the left keeping the 8 bits size
The main thing is that I've tried the program you uploaded and it works, but at the moment I'm combining with the decoding (bin->text) it works unusually and here is the problem I'm facing
The idea is that you won't get less than 8 bits because you will get a new bit for the bit you lost. You are always maintaining the same amount of bit. Eg: [1] <- [0101010] <-[1]
Thank you so much for your response. Although, the problem is my code (just few answers above). When trying to use the sequence that is shifting the bits when deleting one of them, the program should decode the sequence into normal text, and it's not working. I tried both parts separately and it works, but joint not. That's the issue.
Exactly! The program itself tries to receive a binary sequence constantly and when it receives the header, the program starts to decide with an ASCII table the message that follows the header (i also thought about using a some bits to show the size of the message to determine when we start to finish the decoding and start again waiting for a new header
So I am guessing you are watching some bit stream but came in in the middle of transmission, and don't have access to any byte delimitting markers that you would get in serial traffic, where the front edge of a byte is stretched out in time?
In that case, you could use the text block that searches for the index in a longer text (binString) of a given short piece of text ('11111111'). Once you have that non-zero index, you can use that to clip off the header and the pre-header, leaving only the stuff past the header.
(Same logic as my left shift, but use the index+7 instead of 1.)
Then take the remainder and eightify it, split at spaces, and do the lookups of the list items in your incomplete ascii table, using '?' as a not found value to keep output neat and aligned right.