Serial.readuntil()

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  if(Serial.available())
  {
    char a=Serial.readBytes(char,6)
    Serial.println(a);
  }

my idea is to read upto 6 bytes so i used 6(char,6) and to store buffer in character so declared as char(char,6).serial.readuntil function return character stored in buffer so assigned that to char

but i am getting error:"primary expression missing before char"

maybe this due to my poor understanding of that function help me please

readBytes(char

That char, right there.

readBytes(char That char, right there.

what do you try to say.sir

The compiler is asking you what you're doing putting the keyword "char" where you put it.

char is a reserved word, it’s a data type not a variable, you cannot use it there.


Rob

void setup()
{
  Serial.begin(9600);
}
void loop()
{char a[10];
  if(Serial.available())
  {
    char b=Serial.readBytes(a,10  );
    Serial.println(a);
  }
}

sorry about that thanks

and i am getting junk values like input:asd output:asd~ and some times output:asdr

what might be the reason for that

Why don't you print the value of "b"? It may provide some answers.

Serial.available() returns true if there is at least one byte in the buffer. That does not mean you can read 10 bytes(or chars) from the buffer.

Please take time to go through the reference and tutorial section of Arduino.cc There is a lot of information about how to do things in the Arduino language. Time spent there is not lost!