Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float max=10,min=0,need =3,read=0;
- float x1=5,x2=0;
- void setup() {Serial.begin(9600);}
- void loop()
- {
- read=0.7*x1+1;
- if (read<need){
- x2=(max-x1)/2+x1; min=x1; x1=x2;}
- else if (read>need){
- x2=(x1-min)/2+min; max=x1; x1=x2;}
- Serial.print("Read value :");
- Serial.print(read);
- Serial.print(" set value :");
- Serial.print(need);
- Serial.print(" control value:");
- Serial.print(x1);
- Serial.print(" max :");
- Serial.print(max);
- Serial.print(" min :");
- Serial.println(min);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement