#define RX_PIN 44 #define TX_PIN 43 #define NUM_SENSORS 9 #define BAUD 115200 int sensorPins[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; char sensorValues[NUM_SENSORS]; void setup() { Serial1.begin(BAUD, SERIAL_8N1, RX_PIN, TX_PIN); for (int i = 0; i < NUM_SENSORS; i++) { pinMode(sensorPins[i], INPUT); } } void loop() { // Read values from Hall effect sensors for (int i = 0; i < NUM_SENSORS; i++) { int sensorValue = analogRead(sensorPins[i]); // Threshold based on reading // North if (sensorValue < 100) { sensorValues[i] = '2'; } // South else if (sensorValue > 4000) { sensorValues[i] = '1'; } // None else { sensorValues[i] = '0'; } } // Send sensor data to the receiver (using Serial1) for (int i = 0; i < NUM_SENSORS; i++) { Serial1.print(sensorValues[i]); if (i < NUM_SENSORS - 1) { Serial1.print(","); } } Serial1.println(); delay(1000); }