Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //Programma di gestione di un rubinetto a sfera tramite servocomando per poter modulare il vuoto in un impianto
  2. //di laminazione sottovuoto
  3.  
  4. #include <Servo.h>
  5. #define pres_voluta A0
  6. #define pres_reale A1
  7. Servo valvola;
  8. int Var1;
  9. int V1;
  10. float Var2;
  11. float V2;
  12. int S1;
  13.  
  14. void setup() {
  15. pinMode(pres_voluta,INPUT);
  16. pinMode(pres_reale,INPUT);
  17. valvola.attach(9);
  18. Serial.begin(9600);
  19.  
  20. }
  21.  
  22. void loop() {
  23. Var1=analogRead(pres_voluta);
  24. V1=map(Var1, 0,1023,0,100);
  25. V1=25;
  26. Var2=analogRead(pres_reale)*4.88;
  27. V2=map(Var2,1107.63,4904.40,0,93.6);
  28.  
  29. if(V2 > V1)
  30. {
  31. for(S1=0;S1<90;S1++)
  32. valvola.write(S1);
  33. Serial.println(S1);
  34. delay(7);
  35. }
  36. else
  37. {
  38. for(S1=90;S1>0;S1--)
  39. valvola.write(S1);
  40. Serial.println(S1);
  41. delay(7);
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement