ATTINY85 Fuel pressure regulator

Hello everyone.
I have a programming issue. This is an ongoing project from:
https://forum.arduino.cc/t/attiny85-and-latest-ide/1275511/29

I'm trying to get an ATTINY 85 to control an electric fuel pump for a carbureted engine. My schematic is posted. I took a video of my O-scope but i'm not able to upload it.
my issue is that the setup code works. the PsiDrive pin goes high then I get a PWM for a very short time. Mabe 3-4 seconds. then it just drives high again.

what im attempting here is that the ATTINY85 reads and analog sensor and compares that to a predetermined value. That value is dictated by a toggle switch that grounds the IdlePin.
The tiny85 would then compare the actual pressure value from the sensor with the predetermined value and adjust PWM from there.
So why I'm not getting constant PWM is confusing.
(there are some lines of code that are commented out. i did this for testing)

If anybody wants to help, I'd appreciate it.
I'm wanting to make a couple PCB's for myself and a couple friends who have classic cars with electric fuel pumps.

(P.S. I don't want to get into a conversation of carb theory and pumps. I'm just looking to get my code to work and I can adjust as needed)

Thanks

// Fuel Pressure Regulator

// INPUTS
const int IdlePin = 1;
const int PsiSense = 2;

// OUTPUTS
int PsiDrive = 0;

// VARIABLES & STATES
bool IdleState;
int PsiVal;         // Value assigned by analog read of 0.5 to 4.5v from Pressure sense pin
int PsiRef;         // values set by idle state, values are direct ADC values.
int DriveVal;       // PWM value
int Error;
int Timer;
unsigned long TimeNow;
unsigned long TimeThen;

void setup() {
  pinMode(IdlePin, INPUT);
  pinMode(PsiSense, INPUT);
  pinMode(PsiDrive, OUTPUT);
  digitalWrite(PsiDrive, HIGH);
  Timer = 1000;
  TimeThen = 0;
  Error = 25;
  DriveVal = 180;
  delay(5000);
  digitalWrite(PsiDrive,LOW);    
}

void loop() {
  //TimeNow = millis();
  PsiVal = analogRead(PsiSense);
  IdleState = digitalRead(IdlePin);
  DriveVal = constrain(DriveVal,130,255);
  analogWrite(PsiDrive, DriveVal);

  // checks idle state and current fuel pressure
  //if (TimeNow - TimeThen >= Timer) {
    //IdleState = digitalRead(IdlePin);
    //PsiVal = analogRead(PsiSense);
    //TimeThen = TimeNow;
  //}

  // sets desired pressure to 4 psi
  if (IdleState == false) {
    PsiRef = 765;
  }
  // sets desired pressure to 2.75 psi
  if (IdleState == true) {
    PsiRef = 375;
  }
  // decrease PWM value to lower pressure
  if (PsiVal - PsiRef >= Error) {
    DriveVal --;
  }
  // increase PWM value to raise pressure
  if (PsiVal - PsiRef <= Error) {
    DriveVal ++;
  }
  // if sensor fails, default to full drive
   // if ((PsiVal >= 1000) || (PsiVal <= 23)) {
   //   digitalWrite(PsiDrive, HIGH);
   // }
}

It is adviseable to use a Development System (like: Digispark/Clone ATtiny85 Dev Board) while building a complex type Project. A Dev System helps to
to trouble shoot hardware and debugg software.

Do you own these gadgets:
AVR programmer
ROM programmer
Arduino UNO
Arduino NANO
Jumpers
LEDs
Resistors
DVM
etc.

You need a stable power supply for the processor to work correctly. If you read the data sheet for the 7805 you are using you will find they want a high frequency bypass capacitor on the inlet, usually in the 0,33ouf. Some want bypassing on both the in and out. Check the manufacturers data sheet for your 7805. Also add another at the processor.

I have all but those types of programmers. I’m using a Nano as ISP.
I do have a fairly decent stash of components except for caps. That’s why I’m using the values given in the schematic. That’s what I have on hand that isn’t obnoxious. I’ll have to order more.

// Fuel Pressure Regulator ATtiny85

// INPUTS
const int IdlePin = 1;
const int PsiSense = 2;

// OUTPUTS
int PsiPWM = 0;

// VARIABLES & STATES
bool IdleState;
int PsiVal;         // Value assigned by analog read of 0.5 to 4.5v from Pressure sense pin
int PsiRef;         // values set by idle state, values are direct ADC values.
int Val;       // PWM value
int Error;

void setup() {
  pinMode(IdlePin, INPUT);
  pinMode(PsiSense, INPUT);
  pinMode(PsiPWM, OUTPUT);
  digitalWrite(PsiPWM, HIGH);

  Error = 25;
  Val = 180;
  delay(5000);
  digitalWrite(PsiPWM, LOW);
}

void loop() {
  PsiVal = analogRead(PsiSense);
  IdleState = digitalRead(IdlePin);

  if (IdleState )PsiRef = 375; // sets desired pressure to 2.75 psi
  else PsiRef = 765; // sets desired pressure to 4 psi

  // decrease PWM value to lower pressure
  if (PsiVal - PsiRef > Error) {
    Val --;
  }
  // increase PWM value to raise pressure
  if (PsiVal - PsiRef < -Error) {
    Val ++;
  }

  Val = constrain(Val, 130, 255);
  analogWrite(PsiPWM, Val);
}

That is a bit cleaner....
I'll give that a try.