Another string question, and serial too

Hello all,

I am trying to

  1. create a string pointing to the value of a variable(s)
  2. using Serial.print, send that string/value to a laptop for datalogging/viewing with this program www.tunerpro.net
  3. use strcat to append several values to the string and send that string to serial so that they are sent (coming into the laptop) consecutively.
    Here is the basic code I am using. I get an error " initializer expression list treated as compound expression" when attempting to compile.
 char tps = A0;
char tpsval = 0;
char PWM_1 = 0;
char tpvolt = 0;
char dataOut[] = {tpvolt,PWM_1};

void setup()
{
  Serial.begin(9600);
}
void loop()
{
 
  int tpsval = analogRead(tps);
  char tpvolt = map(tpsval,0,1023,0,255);
  char PWM_1 = map(tpsval,0,1023,255,0);
 char strcat(tpvolt,PWM_1);
  
  Serial.print(dataOut);
  delay(5);
}

I am needing to send the values of "tpvolt" and "PWM_1" out to serial. In Tunerpro I get the desired value of tpvolt but I get nothing relating to PWM_1. Im stumped. Surely it's something simple as it usually is. Any insight is greatly appreciated.

Bill

  1. create a string pointing to the value of a variable(s)

This doesn't make sense.

  char tpvolt = map(tpsval,0,1023,0,255);

That's an expensive way to divide by 4.

Here is the basic code I am using. I get an error " initializer expression list treated as compound expression" when attempting to compile.

Referencing what line?

 char strcat(tpvolt,PWM_1);

This one? What do you think you are doing here? Why are you trying to concatenate a char to a char? Both arguments need to be string (NULL terminated ARRAYS of chars). The result is NOT a char.

I don't read your post, but I saw this:

char dataOut[] = {tpvolt,PWM_1};

What is supposed to be this?

Billdefish:
I am needing to send the values of "tpvolt" and "PWM_1" out to serial.

What's wrong with this ?

Serial.print(tpvolt);
Serial.print(PWM_1);

...R

probably better to separate them

e.g.

Serial.println(tpvolt);
Serial.println(PWM_1);

Otherwise I don't know how you'd tell where tpvolt ended and PWM_1 starts

rogerClark:
Otherwise I don't know how you'd tell where tpvolt ended and PWM_1 starts

I thought each of them was a char or a byte.

...R

 char strcat(tpvolt,PWM_1);

strcat is one char, not two.

Also why make global and local variables the same?