Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float numeroCil = 6;
- unsigned long tempoInicial;
- unsigned long pulsos;
- float rpm = 0;
- //-----------------------------------
- void ContaPulsos()
- {
- pulsos++;
- }
- //------------------------------------
- void setup()
- {
- Serial.begin(9600);
- pulsos = 0;
- attachInterrupt(0, ContaPulsos, RISING);
- tempoInicial = millis();
- }
- //------------------------------------
- void loop()
- {
- if ((millis() - tempoInicial) >= 200)
- {
- tempoInicial = millis();
- rpm = (((float)pulsos / ((float)numeroCil / 2)) ) * 300;
- Serial.println(rpm,0);
- pulsos = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement