Ok I connected the fans ground to one of the arduinos ground pins and I am still getting noting but random rmp numbers. Did I connect the resistor wrong? Does the sketch look right?
This is how I have it wired currently.
and the code
volatile byte NbTopsFan;
int hallsensor = 2;
void rpm()
{
NbTopsFan++;
}
/***************************************/
void setup()
{
// pinMode(hallsensor, INPUT);
Serial.begin(9600);
attachInterrupt(0, rpm, RISING);
};
void loop ()
{
NbTopsFan = 0;
delay (1000);
NbTopsFan = NbTopsFan * 30;
Serial.print (" ");
Serial.print (NbTopsFan, DEC);
Serial.print (" rpm");
};