#include #include LiquidCrystal_I2C lcd(0x20,16,2); // LCD address to 0x20 (16 chars on 2 line) volatile float time = 0; volatile float time_last = 0; void setup() { lcd.init(); lcd.backlight(); lcd.setCursor(0,0); // (col,row) lcd.print("rpm: "); attachInterrupt(0, rpm_interrupt, RISING); //Pin 2 As Interrupt ( if signal increase) } void loop() { // Loop To Calculate RPM and Update the LCD Display int rpm = 0; while(1){ delay(500); //Slow Down Display Updates ( half second) if(time > 0) { rpm = 60*(1000000/(time)); lcd.setCursor(0,1); lcd.print(rpm); } } } void rpm_interrupt() { //Capture The OPB704 Beam =>Interrupt time = (micros() - time_last); time_last = micros(); }