Converting into a string

Hi guys, I'm currently working on a project to control a selection of lights on my car for offroading and in order to distribute power and control I want to use an arduino in order to give me the flexibility I need.

In order to debug the system and also analyse any hardware faults I want to be able to get feedback through the serial port so that I can plug my laptop in and receive the data bits from the device.

Currently I am having some trouble sending the input and output signals via the serial port. I'm sure it must be my conversion of the integer thats causing the problem but when I send my outString it seems to override the string and only send me the single digit integer. If I remove the "&& String(master)" then I receive the string correctly.

Thanks in advanced for any help.

//INPUT HANDLE int master=0;

void loop() { // put your main code here, to run repeatedly: delay(1); //Serial.println( outString = "master = " && String(master);

Serial.println(outString);

delay(500);

}

&& does not do what you think it does, and I can't imagine why you think it would. Other than that I don't comment on Strings.

Jaykay998: If I remove the "&& String(master)" then I receive the string correctly.

Thanks in advanced for any help.

//INPUT HANDLE int master=0;

void loop() { // put your main code here, to run repeatedly: delay(1); //Serial.println( outString = "master = " && String(master);

Serial.println(outString);

delay(500);

}

&& means logical AND.

You want '+'

I must have had errors elsewhere in my code, typically I've just tried it on a simple string and it's worked correctly.

Sorry for the derp and thanks for the help.

Jaykay998: I must have had errors elsewhere in my code, typically I've just tried it on a simple string and it's worked correctly.

I can't figure out how it worked since you have not defined outString anywhere that I can see. I also agree with Keith that it's a poor choice to use a String object (note the capital 'S') versus a standard C string (lower case 's').

econjack: I can't figure out how it worked since you have not defined outString anywhere that I can see. I also agree with Keith that it's a poor choice to use a String object (note the capital 'S') versus a standard C string (lower case 's').

For beginners who are not doing much in terms of memory, it's ok to use String instead of char string.

mistergreen: For beginners who are not doing much in terms of memory, it's ok to use String instead of char string.

No, it isn't. Sooner or later, the training wheels have to come off. Start with the String class, and you have to unlearn a lot of bad habits. Start with C styles string and be where you need to be.

OP: There is NOT advantage in trying to send the data with one Serial.print() statement. Use two!