Problems with readBytes.

Hello everyone, I recently got my Leonardo board and started programming a simple fan controller for use on my PC.

I want it to communicate with the computer via the serial com port and that's what I'm having a bit of trouble with.

First off, I'm very fresh with c++ and I'm learning as I go.

The error I am having now is when I call the readBytes command, I receive the peculiar compiler error

Invalid conversion from 'char' to 'char*'

I would think this is difficult as they're both the same variable types, as such I suspect the * to be the culprit in this. I'm really not sure what to make of it, I tried a bit of google and the closest match to my issues was that it's a pointer of some sort.

This is the code that won't compile:

    do if (Serial.available() > 0){
	int bytes=Serial.available();
	Serial.readBytes(buffer, bytes);
}

To be honest I'm not too sure exactly hoe readBytes works, from my understanding it should be possible to read the amount of data available in the serial buffer and allocate that to a variable in order to use it to extract the data later on.

Hi DrJones

Sounds like a problem with how you have declared buffer. Please post your complete program so we can check.

Regards

Ray

You might also like to look at how data input is done in the demos here and here

...R