Hello again and many thanks for the help, I feel I have had a productive day, I've rewritten the sketch again so here is a newer and improved version from earlier. The LCD now displays "0" when drill is not running and updates every 1 sec, appears from initial testing to be reasonably accurate but I suspect that this sketch is accurate to +/-60RPM
#include <LiquidCrystal.h>
int sensorPin = 2; //hall effect
int ledpin = 13;
float revs;
float rpm;
volatile byte rpmcount;
long previousmicros = 0;
long interval = 1000000;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
/*
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D0 pin to digital pin 1
* LCD D1 pin to digital pin 10
* LCD D2 pin to digital pin 11
* LCD D3 pin to digital pin 12
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
void setup()
{
// setup serial - diagnostics - port
Serial.begin(115200);
// setup pins
pinMode(sensorPin, INPUT);
pinMode(ledpin, OUTPUT);
// setup interript
attachInterrupt(0, RPM, RISING);
}
void RPM()
{
rpmcount++;
}
void loop()
{
unsigned long currentmicros = micros();
int sensorValue = digitalRead(sensorPin);
if (currentmicros - previousmicros > interval) {
previousmicros = currentmicros;
detachInterrupt(0);
revs=1000000.0/rpmcount;
rpm = 60000000.0/revs;
Serial.print("rpmcount\t");
Serial.print(rpmcount);
Serial.print(" rpm\t");
Serial.println(rpm);
lcd.clear();
lcd.begin(16, 2);
lcd.print(" DRILL SPEED");
lcd.setCursor(9, 1);
lcd.print(" RPM");
lcd.setCursor(3,1);
lcd.print(rpm,0);
rpmcount=0;
attachInterrupt(0, RPM, RISING);
}
if (sensorValue == 0) {
digitalWrite (ledpin, HIGH);
}
else {
digitalWrite(ledpin, LOW);
}
}