Serial Print Digital Read AND plain text in one line

Goal: Send response sms to display readout of digital inputs(valve positions) or other parameter WITH plain text. I used the serial print wording because it is similiar in what i am trying to accomplish, however i cant just do multiple serial print lines, as im trying to send ONE text message.
** **  int valve1state = digitalRead(relay1);     int valve2state = digitalRead(relay2);     int valve3state = digitalRead(relay3);     int valve4state = digitalRead(relay4);** **
The 4G device sends sms in this format:
** ** error = _4G.sendSMS( phone_number, "sms body");** **
I am looking to send something like
** **[code] error = _4G.sendSMS( phone_number, ("Valve Positions: \n) + (valve1state) (valve2state) + (valve3state);** **
But it doesnt send the status
Second: If i serial print the status, it prints 0 or 1... if i define the valve state as a char, will it print HIGH/LOW instead of 0/1? And if so, can i customize it to instead print Open for 1 ect..

Have a look at snprintf() :slight_smile:

You can use snprintf to store a formated text into a buffer. Then you can send this buffer out with the sendSMS function

char buffer[64];
snprintf(buffer, 64, "Valve positions: %d %d %d %d", valve1state , valve2state , valve3state , valve4state );

If you want to display HIGH/LOW instead of 0 and 1, you can use the ternary operator or use the valve state as an index to an array (only if valvestate can only be 0 or 1!).

char buffer[64];
const char* textValues[] = 
{
    "LOW",
    "HIGH"
};
snprintf(buffer, 64, "Valve positions: %s %s %s %s", textValues[valve1state], textValues[valve2state], textValues[valve3state], textValues[valve4state]);