Int value servo control and program flow

image

#include <LiquidCrystal.h>
 
#define rs 9 
#define en 8 
#define d4 7 
#define d5 6  
#define d6 5 
#define d7 4 
 
volatile byte freqcount;
unsigned int frequency;
unsigned long timeold;
int frequency1;
 
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
 
 
void freq_fun()
 {
   //ac cycle, this interrupt function is run twice, so take that into consideration for 
   //calculating frequency
   //Update count
      freqcount++;
 }
 
void setup()
 {
   lcd.begin(16, 2);  // intialise the LCD
   Serial.begin(9600);
 
   //Interrupt 0 is digital pin 2, so that is where the output from the transistor is connected
   //Triggers on FALLING (change from HIGH to LOW)
   attachInterrupt(0, freq_fun, FALLING);
 
 
 
   freqcount = 0;
   frequency = 0;
   timeold = 0;
 }
 
 void loop()
 {
   //Update frequency every second
   delay(1000);
   //Don't process interrupts during calculations
   detachInterrupt(0);
 
    frequency = 60*50/(millis() - timeold)*freqcount; 
   timeold = millis();
   freqcount = 0;
 
 
   Serial.print("Frequency: ");
   frequency1 = frequency/4;
   
   Serial.println(frequency1);
     //Print out result to lcd
   lcd.clear();
   lcd.print("Frequency=");
   lcd.print(frequency1); 
   
 
   //Restart the interrupt processing
   attachInterrupt(0, freq_fun, FALLING);
  }

This is what I started with. The example is provided by Electronics Clinic.
I am using an optocoupler in my setup. The following is the PCB from the schematic i provided above:

I was in the process of mapping the components to the Arduino pin numbers but didnt quite finish it.

I recently acquired the 993 generac motor and it utilizes a stepper motor for throttle control of a NG carberator.

I have and I2C port built on the PCB which was intended for an lcd but if you think we can salvage the current configuration then we could make use of the I2C for the stepper control. Could we not?