const int hallSensors[] = {D1, D2, D3, D4, D5}; void setup() { // put your setup code here, to run once: Serial.begin(9600); // Initialize the hall sensors as inputs for (int i = 0; i < 5; i++) { pinMode(hallSensors[i], INPUT); } } void loop() { // put your main code here, to run repeatedly: for (int i = 0; i < 5; i++) { if (digitalRead(hallSensors[i]) == LOW) { Serial.println(i); } } delay(500); }