Need help with Serial Mirrors

hi guys im working with a screen and sound update for bitlash

My arduino unos connection:
Mirror Bitlash
00000000000000000021------------------------------------------21000000
00131211109876543210 131211109876543210
00000000000000000000 000000000000000000
00000000000000000000 000000000000000000
extras for bitlash:

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);
    tft.print(readString);
    
         if (readString.startsWith("RECTSH"))
   {
       Serial.println(readString.substring(23, 28));
    tft.fillRect(readString.substring(7, 10).toInt() , readString.substring(11, 14).toInt()  ,  readString.substring(15, 18).toInt(), readString.substring(19, 22).toInt(), readString.substring(23, 28).toInt());
       tft.drawRect(readString.substring(7, 10).toInt() , readString.substring(11, 14).toInt()  ,  readString.substring(15, 18).toInt(), readString.substring(19, 22).toInt(), readString.substring(23, 28).toInt());


  }
         if (readString.startsWith("CIRCSH"))
   {
    tft.fillCircle(readString.substring(7, 10).toInt() , readString.substring(11, 14).toInt() , readString.substring(15, 18).toInt(), readString.substring(19, 24).toInt());

  } 
           if (readString.startsWith("BITMAP"))
   {
    drawBitmap(readString.substring(7, 10).toInt() , readString.substring(11, 14).toInt()  ,  readString.substring(15, 18).toInt(), readString.substring(19, 22).toInt(), Bitmap1);

  } 

Mirror Code

void setup() {
    Serial.begin(115200);
    //Serial.begin(9600);
    Serial.write('B');
}

void loop() {
    if (Serial.available() > 0) {
        Serial.write(Serial.read());
    }
}

when i print what i got from bitlash one, test word is basically doesnt stop and i didnt even say

if a byte is available why the H*** would you have to wait for 2ms to arrive in the input buffer :thinking: , it's already there... have you seen this type of coding anywhere?

also at 115200 bauds, you can get 20+ bytes accumulating in your buffer and you extract only one (19 pending). Then you loop and accumulate 20 more and read one ➜ 38 pending. Do that a few time and you'll reach the end of the buffer (64 bytes) and you'll start loosing data

I would suggest to study Serial Input Basics to understand how to deal with Serial input correctly

When you write without proofreading, how do you expect to communicate?

Actually the problem i say is happens probally here

Char serialcode=serial.read()
Void loop()
{
if(serialcode=='s')
{
Serial.println("testdone")//it starts spamming on startup//
serialcode=''
}
}

And we are supoosed to know that how? That is nowhere in your original code snippets.

Can you please post full code.

If that's outside any function, it's wrong.

@gaouser
Please use code tags. </> It makes even the poorest code at least a little more readable.
You've probably been told to read this:

before, but clearly you should read it<again?>. Getting help around here is a whole lot easier when the helpers think you're wanting to play along.
C

Ahh, I see you retro'd your posting, but were quoted by others in the meantime, which captured your unformmated content.
Apologies.
C

Hi,

No apology needed
@gaouser please do not got back and edit old posts, it causes confusion with the flow of the thread.
Please add your corrections in new posts.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

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