ما الخطاء في هذا البرنامج لا يمكن اخراج PWM
كود:
int potentiometer = A0;
int feedback = A1;
int VIN = A2;
int PWM = 3;
int pwm = 0;
float V1=0;
void setup() {
pinMode(potentiometer, INPUT);
pinMode(feedback, INPUT);
pinMode(VIN, INPUT);
pinMode(PWM, OUTPUT);
TCCR2B = TCCR2B & B11111000 | B00000001; // pin 3 and 11 PWM frequency of 31372.55 Hz
}
void loop() {
float Vp = analogRead(potentiometer);
float output1 = analogRead(feedback);
float Vin1 = analogRead(VIN);
float output = ((5.1+20)*output1)/5.1;
float Vin = ((5.1+20)*Vin1)/5.1;
float D = ( Vp/1023);
float Vout = Vin * (1-D);
while (output != Vout)
{
if (Vout > output)
{
Vp = Vp-1;
}
if (Vout < output)
{
Vp = Vp+1;
}
int Vpo= map(Vp,0,1024,0,225);
analogWrite(PWM,Vpo);
float output1 = analogRead(feedback);
float output = ((5.1+20)*output1)/5.1;
}
}