Hello Im trying to come up with a pressure regulator using the PWM pins and a solenoid to regulate pressure for a waste oil burner I am using. I found a boost controller code I modified to hopefully work. The project is still in the early stages and I am not great with code. The code I borrowed is for a rev 1 Uno and I am using a r4 WiFi. Code below. I get an error which is also marked below when verifying the code im assuming it is from the differences in boards. Would I need to come up with a different code all together or is there another way to achieve the frequency change while still using this code? I'm not familiar with how to use the pwm to change the pulse of the solenoid to regulate pressure. Thanks in advance for taking time to help.
#include <PID_v1.h>
double Setpoint,Input,Output;
const int analogIn = A3;
const int setpointIn = A4;
float scaledSP;
float scaledPV;
float scaledOut;
PID myPID(&Input,&Output,&Setpoint,7,1,0,DIRECT);
void setup(){
//set pwm frequency to 30.64hz
TCCR1B = TCCR1B & B11111000|B00000101; //Error when verifying
pinMode(analogIn,INPUT);
pinMode(setpointIn,INPUT);
Input=analogRead(0);
Setpoint=analogRead(1);
myPID.SetMode(AUTOMATIC);
}
void loop(){
scaledSP=(Setpoint*250)/1024-25.5;
scaledPV=(Input*250)/1024-24;
scaledOut=(Output*100)/255;
Input=analogRead(0);
Setpoint=analogRead(1);
myPID.Compute();
analogWrite(10,Output);
}