Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Programma di gestione di un rubinetto a sfera tramite servocomando per poter modulare il vuoto in un impianto
- //di laminazione sottovuoto
- #include <Servo.h>
- #define pres_voluta A0
- #define pres_reale A1
- Servo valvola;
- int Var1;
- int V1;
- float Var2;
- float V2;
- int S1;
- void setup() {
- pinMode(pres_voluta,INPUT);
- pinMode(pres_reale,INPUT);
- valvola.attach(9);
- Serial.begin(9600);
- }
- void loop() {
- Var1=analogRead(pres_voluta);
- V1=map(Var1, 0,1023,0,100);
- Var2=analogRead(pres_reale)*4.88;
- V2=map(Var2,1107.63,4904.40,0,93.6);
- if(V2 > V1)
- {
- for(S1=0;S1<90;S1++)
- valvola.write(S1);
- Serial.println(S1);
- delay(7);
- }
- else
- {
- for(S1=90;S1>0;S1--)
- valvola.write(S1);
- Serial.println(S1);
- delay(7);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement