I have four signal Red, Green, Blue and yellow. One of signals which is yellow moves very slowly as compared to others. Need help to solve problem.

float Reference;

float Refvalue;

float sensorvalue;

const int inputvalve = 5;

const int outputvalve = 6;

const int sensor = A0;

void setup(){

Serial.begin(9600);

TCCR0B = TCCR0B & B11111000 | B00000101;

pinMode(inputvalve, OUTPUT);

pinMode(outputvalve, OUTPUT);

pinMode(sensor, INPUT);

}

void loop (){

Reference=147;

Refvalue=26.80;

sensorvalue=analogRead(sensor);

float voltage=(sensorvalue/1024)*5.0;

float Pressure = (voltage/0.0266);

double output = ((167.7-sensorvalue)/0.7);

float error = (Refvalue-Pressure);

char str[300];

sprintf(str, "%d.%02d, %d.%02d, %d.%02d, %d.%02d", (int)Refvalue,(int)(Refvalue*100)%100, (int)Pressure,(int)(Pressure*100)%100, (int)output,(int)(output*100)%100, (int)error,(int)(error*100)%100);

Serial.println(str);

if(sensorvalue < Reference){

analogWrite(inputvalve, 0);

analogWrite(outputvalve, 255);

}

else if(sensorvalue > Reference){

analogWrite(inputvalve, 255);

analogWrite(outputvalve, 0);

}

else if(sensorvalue == Reference){

analogWrite(inputvalve, 255);

analogWrite(outputvalve, 255);

}

}

More Waheed Ur Rehman's questions See All
Similar questions and discussions