Thanks the code
[code//code by Crenn from http://thebestcasescenario.com
//project by Charles Gantt from http://themakersworkbench.com
//second fan added by steven m
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 13, 4, 5, 6, 7);
/*To disable interrupts:
cli(); // disable global interrupts
and to enable them:
sei(); // enable interrupts
*/
//Varibles used for calculations
int NbTopsFan;
volatile int NbTopsFan1;
volatile int NbTopsFan2;
int Calc1;//???
int Calc2; //???
int hallsensor1 = 2; //The pin location of the sensor
int hallsensor2 = 3; //The pin location of the sensor
typedef struct{ //Defines the structure for multiple fans and their dividers
char fantype;
unsigned int fandiv;
}fanspec;
//Definitions of the fans
fanspec fanspace[3]={{0,1},{1,2},{2,8}};
char fan = 1; //This is the varible used to select the fan and it's divider, set 1 for unipole hall effect sensor
//and 2 for bipole hall effect sensor
void rpm1 () //This is the function that the interupt calls
{
NbTopsFan1++;
}
void rpm2 () //This is the function that the interupt calls
{
NbTopsFan2++;
}
//This is the setup function where the LCD is initialised,
//and the interrupt is attached
void setup()
{
lcd.begin(20, 4); //Set up the LCD's number of rows and columns
pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
pinMode(hallsensor2, INPUT);
attachInterrupt(0, rpm1, RISING); //and the interrupt is attached mube pin 2
attachInterrupt(1, rpm2, RISING); // must be pin 3
}
void loop ()
{
NbTopsFan1 = 0; //Set NbTops to 0 ready for calculations
NbTopsFan2 = 0;
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc1 = ((NbTopsFan1 * 60)/fanspace[fan].fandiv); //Times NbTopsFan (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider
Calc2 = ((NbTopsFan2 * 60)/fanspace[fan].fandiv); //Times NbTopsFan (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider
lcd.setCursor(0, 3);
lcd.print ("Fan1:"); //Prints " Fan1:"
lcd.setCursor(5, 3);
lcd.print (Calc1, DEC); //Prints the number calculated above
lcd.setCursor(10, 3);
lcd.print ("Fan2:"); //Prints " Fan2:"
lcd.setCursor(15, 3);
lcd.print (Calc2, DEC); //Prints the number calculated above
}]