active low,
tempel pake isolasi double tape buat actifin buat ukur speed fan
#include<LiquidCrystal.h>
//LiquidCrystal lcd(12,11,6,5,4,3);
LiquidCrystal lcd(12, 11, 5, 4, 3, 10);
const byte blade = 1;
float value=0;
float rev=0;
int rpm;
int oldtime=0;
int time;
void isr() //interrupt service routine
{
rev++;
}
void setup()
{
lcd.begin(16,2); //initialize LCD
attachInterrupt(0,isr,FALLING); //attaching the interrupt
}
void loop()
{
delay(1000);
detachInterrupt(0); //detaches the interrupt
time=millis()-oldtime; //finds the time
rpm=(rev/time)*60000/blade; //calculates rpm
oldtime=millis(); //saves the current time
rev=0;
lcd.clear();
lcd.setCursor(1,0);
lcd.print("___TACHOMETER___");
lcd.setCursor(1,1);
lcd.print( rpm);
lcd.print(" RPM");
lcd.print(" ");
attachInterrupt(0,isr,FALLING);
}