UKHeliBob:
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
}
}
}
[/quote Ok maybe I'll try to go try this code once but can you please let me know what algorithm are you using to detect the output of sensors ( kindly correct me if I'm wrong somewhere cuz I am a noobie to all this stuff). Secondly, I was a bit confused if there's any difference in pinchangeInterrupt and external interrupt. **Could you please help me know how can I use pinchangeInterrupt to run interrupt routine on more than 2 pins?**