it will be kind of you to tell me if any other way is possible.
This is the sort of thing that I had in mind but I have no way of testing it as I don't have the hardware required.
const byte sensorPins[] = {10, 11, 12};
unsigned long previousTimes[3];
const byte TOTAL_SENSORS = sizeof(sensorPins) / sizeof(sensorPins[0]);
void setup()
{
Serial.begin(115200);
for (int s = 0; s < TOTAL_SENSORS; s++)
{
pinMode(sensorPins[s], INPUT_PULLUP);
}
}
void loop()
{
unsigned long currentTime = millis();
for (int s = 0; s < TOTAL_SENSORS; s++)
{
if (digitalRead(sensorPins[s]) == HIGH)
{
unsigned long period = currentTime - previousTimes[s];
previousTimes[s] = currentTime;
//code here to calculate RPM for sensor based on the period
}
}
}