Air motor Tachometer and Speed Control

New to Adruino. I have no code experince.
Very interested in learning though.

Need to control an air motor speed to a set set speed.
Would like to read rpm and push a button to set the speed.
If the load draws the motor down a certian % of the set speed I need to pull open a solonoid to add air to increase rpm back to set speed.

Have a sqaure wave input for speed reference. 4 Low's=1 revolution.
Will use pin 2 as input reference. and pin 6 as HIGH output to a pwr transistor to send 12vdc to the solinoid.

Ive played with this scetch I found on the forum under search for tachometer: Can't remember who posted it though.
But not experienced enough to figure out how to mod for my use.
Any help would be very much appreciated.

#include <LiquidCrystal.h>
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
int pin = 2;

//LiquidCrystal lcd(12, 13, 11, 10,9,8,7);

void rpm_fun()
{pinMode(2, INPUT);
//Update count
rpmcount++;
}

void setup()

{Serial.begin(9600);

attachInterrupt(0, rpm_fun, RISING);
rpmcount = 0;
rpm = 0;
timeold = 0;

}

void loop()

{
delay(200); // Sample Time
detachInterrupt(0);

rpm = (millis() - timeold) / rpmcount;
rpm = 1000/rpm;
rpm = (rpm / 4) * 60; // Six Cyl - 3 PPR
timeold = millis();
rpmcount = 0;

lcd.clear();
lcd.setCursor(0, 0);
lcd.print(int(rpm)); // print rpm
Serial.print(int(rpm));
//Restart the interrupt processing
attachInterrupt(0, rpm_fun, RISING);

}