comment l'appliquer à ce code qui permet de lire et d'afficher la vitesse rpm :
unsigned byte rpmcount;
float rpm;
unsigned long timeold;
void setup()
{
Serial.begin(9600);
attachInterrupt(0, rpm_fun, RISING);
}
void loop() {
if (rpmcount >= 20) {
rpm = 60*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
Serial.println(rpm);
}
void rpm_fun()
{
rpmcount++;
//Each rotation, this interrupt function is run twice
}
merci