Mysterious error when compiling Serial.write

According to Arduino Referenc for Serial.write, the following should be possible:

char Data [255];

Serial.write (Data, 255);

The compiler murmurs and brings an error message:

invalid conversion from 'char' to const unit0_t (aka const unsigned char
"}" [fpermissive]

Is the referenc wrong or what could be the mistake?
Is it possibly a version issue ???

Please cut and paste the actual message into your post, not one that you vaguely recall, and post the actual code, using code tags. Also, check whether the message is a warning rather than an error.

Did you really plan to send 255 bytes of random, uninitialized nonsense out the serial port?

Serial.write (Data, 255);

expects uint8_t* and you have passed it a char*

Serial.write ((uint8_t*)Data, 255);

will fix the error, but as @jremington said there may be other problems.

Check out my SafeString library (available from Arduino Library manager) if you are going to be working with char[] or c-strings.

and, depending on what you put in that array Data[], you may be better off using Serial.print().

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