Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
volatile int NbTopsFan;
int Calc;
int hallsensor = 2;
float contadorPulsos;
float pulsosAuxiliares;
float pulsosAnteriores;
void rpm ()
{
NbTopsFan++;
}
void setup()
{
pinMode(hallsensor, INPUT);
Serial.begin(9600);
attachInterrupt(0, rpm, RISING);
}
void loop ()
{
cli();
pulsosAuxiliares = pulsosAuxiliares;
sei();
if ( (pulsosAuxiliares != 0) && (pulsosAnteriores == pulsosAuxiliares) ) {
Serial.print("pulses:");
Serial.println (pulsosAuxiliares, DEC);
cli();
pulsosAuxiliares = 0;
sei();
pulsosAnteriores = 0;
pulsosAuxiliares = 0;
}
cli();
pulsosAnteriores = pulsosAuxiliares;
sei();
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.