I have a project where i am reading numerous digital inputs (15) and directing them to a serial output (serial1), which is a RS232 Output (via MAX3232), monitoring the activity via tera Term. As i connect the digital inputs one at a time to pins 22-36 individual some of the pins give be a dual output. (see screen shot) cant figure out why some inputs behave as expected and other don't.
OUTPUT:
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
INPUTS:0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
here is the code:
#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(115200); // Serial Monitor via USB
Serial1.begin(115200); // RS232 Output to AVL (via MAX3232)
for (int i = 0; i < NUM_INPUTS; i++) {
pinMode(inputPins[i], INPUT);
}
}
void loop() {
String data = "INPUTS:"; // Start the message
for (int i = 0; i < NUM_INPUTS; i++) {
data += String(digitalRead(inputPins[i])); // Read each input and append to message
if (i < NUM_INPUTS - 1) data += ","; // Add comma between values
}
Serial.println(data); // Send to Serial Monitor (USB)
Serial1.println(data); // Send to AVL device via RS232
delay(2000); // Adjust as needed
}
