Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile unsigned int pulsos = 0;
- volatile unsigned long t;
- //-------------------------------
- void ContaPulso()
- {
- pulsos++;
- }
- //-----------------------------
- void setup()
- {
- Serial.begin(9600);
- attachInterrupt(0, ContaPulso, RISING);
- pinMode(2,INPUT_PULLUP);
- t = millis();
- }
- void loop()
- //------------------------------
- {
- if ((millis() - t) >= 1000)
- {
- int rpm = pulsos * 60;
- Serial.print("RPM = ");
- Serial.println(rpm);
- t = millis();
- }
- pulsos = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement