on a 2560 my code outputs fine on serial1 print. basically 1's and 0's from digital inputs. but when i add the serial1 write there is not output from serial1. below is my code. this is connected via rs232 in a terminal window.
#define NUM_INPUTS 15 // Number of inputs
const int inputPins[NUM_INPUTS] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36};
void setup() {
Serial.begin(9600); // Serial Monitor via USB
Serial1.begin(9600); // RS232 Output to AVL (via MAX3232)
for (int i = 0; i < NUM_INPUTS; i++) {
pinMode(inputPins[i], INPUT_PULLUP);
}
}
void loop() {
byte pinStates[NUM_INPUTS] = {0}; // Array to hold pin states
String data = "INPUTS:"; // Start the message
for (int i = 0; i < NUM_INPUTS; i++) {
int sensorValue = digitalRead(inputPins[i]);
pinStates[i] = !sensorValue; // Invert the reading
data += String(pinStates[i]); // Append state to string
if (i < NUM_INPUTS - 1) data += ","; // Add comma between values
}
Serial.println(data); // Send to Serial Monitor (USB)
Serial1.write(pinStates, NUM_INPUTS); // Send binary data to AVL device via RS232
delay(2000); // Adjust as needed


