HEY GUYZ !!!
IN THIS PROJECT I WILL SHOW YOU HOW TO MAKE RPM COUNTING MACHINE
VIDEO
R Sensor Arduino VCC----------------5V GND----------------GND OUT-----------------2(digital pin no. 2) 16X2 LCD Arduino VSS------------------ GND VCC----------------- +5V VEE------------------ POT RS-------------------- 12 R/W----------------- GND E--------------------- 11 DB0---------------- DB1---------------- DB2---------------- DB3---------------- DB4------------------ 6 DB5------------------ 5 DB6------------------ 4 DB7---------------- 3 LED+--------------- +5V LED----------------- GND
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,6,5,4,3);
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 Display
attachInterrupt(0,isr,RISING); //attaching the interrupt
}
void loop()
{
delay(1000);
detachInterrupt(0); //detaches the interrupt
time=millis()-oldtime; //finds the time
rpm=(rev/time)*60000; //calculates rpm
oldtime=millis(); //saves the current time
rev=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("___ TACHOMETER ___");
lcd.setCursor(0,1);
lcd.print( rpm);
lcd.print(" RPM");
lcd.print(" ");
attachInterrupt(0,isr,RISING);
}
R Sensor Arduino VCC----------------5V GND----------------GND OUT-----------------2(digital pin no. 2) 16X2 LCD Arduino VSS------------------ GND VCC----------------- +5V VEE------------------ POT RS-------------------- 12 R/W----------------- GND E--------------------- 11 DB0---------------- DB1---------------- DB2---------------- DB3---------------- DB4------------------ 6 DB5------------------ 5 DB6------------------ 4 DB7---------------- 3 LED+--------------- +5V LED----------------- GND
code
LiquidCrystal lcd(12,11,6,5,4,3);
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 Display
attachInterrupt(0,isr,RISING); //attaching the interrupt
}
void loop()
{
delay(1000);
detachInterrupt(0); //detaches the interrupt
time=millis()-oldtime; //finds the time
rpm=(rev/time)*60000; //calculates rpm
oldtime=millis(); //saves the current time
rev=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("___ TACHOMETER ___");
lcd.setCursor(0,1);
lcd.print( rpm);
lcd.print(" RPM");
lcd.print(" ");
attachInterrupt(0,isr,RISING);
}