Guest User

temperatura arduion e javafx

a guest
May 26th, 2022
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3.  
  4. // sensor temperatura port 2
  5. #define ONE_WIRE_BUS 2
  6.  
  7. //rele ligar/desligar ventilador/ar
  8. #define ObjVent 4
  9.  
  10. OneWire oneWire(ONE_WIRE_BUS);
  11. DallasTemperature sensor(&oneWire);
  12.  
  13. //referencia para temperatura final
  14.  
  15. float conttemperatura1=0;
  16.  int conttemperatura2=0;
  17.  int cont1=0;
  18.  int pin_modeVent=4;
  19.  int  vltemp=29;
  20.  
  21. void setup(void)
  22. {
  23.   digitalWrite(4,HIGH);
  24.   Serial.begin(9600);
  25.   delay(145);
  26.   Serial.println("Dallas Temperature library");
  27.  sensor.begin();
  28.  
  29. pinMode(4,OUTPUT);
  30.  
  31.  
  32.  
  33.  
  34. }
  35.  
  36. void loop(void)
  37. {
  38.     //conaando o loop
  39.     cont1= cont1+1;
  40.     delay(100);
  41.     //requisiçao do sensor
  42. sensor.requestTemperatures();
  43.  
  44.  //temperatura atural
  45. delay(100);
  46.  //float dooble int
  47.  conttemperatura1=sensor.getTempCByIndex(0);
  48.  conttemperatura2=conttemperatura1;
  49.  
  50. if(Serial.available()){
  51.   char caracter=Serial.read();
  52.  
  53.   if(caracter=='A'){
  54.    
  55.    
  56.     Serial.println("LIGADO");
  57.     digitalWrite(4,LOW);
  58.     }
  59.    
  60.   if(caracter=='B'){
  61.    
  62.     Serial.println("DESLIGADO");
  63.     digitalWrite(4,HIGH);
  64.     }
  65.    if(caracter=='X'){
  66.     delay( 100);
  67.     vltemp=vltemp+1;
  68.     delay(100);
  69.     Serial.print(" almentando temperatura");
  70.     Serial.println( vltemp);
  71.     delay(100);
  72.    
  73.    
  74.      }
  75.   if(caracter=='Y'){
  76.   delay(100);
  77.     vltemp=vltemp-1;
  78.     delay(100);
  79.     Serial.print(" Diminuindo temperatura");
  80.     Serial.println( vltemp);
  81.  
  82.     delay(100);
  83.    
  84.    
  85.     }
  86.  
  87.  
  88.    
  89.     if(caracter=='K'){//padrao modifique
  90.    
  91.    vltemp=25;
  92.  
  93.  
  94.     }
  95.    if(caracter=='k'){
  96.    
  97.    vltemp=25;
  98.  
  99.     }
  100.   }
  101.  
  102. if(cont1==1){
  103.    Serial.println(conttemperatura1);
  104.  
  105.   delay(100);
  106.   if(conttemperatura1>vltemp){
  107.   Serial.println("+");
  108.  
  109.   }delay(100);
  110.   if(conttemperatura1<vltemp){
  111.     delay(100);
  112.     Serial.println("-");
  113.  
  114.     }delay(100);
  115.   }
  116.  
  117.   if(cont1==3){
  118.  delay(100);
  119.   Serial.println(conttemperatura2);
  120.   delay(100);
  121.   if(conttemperatura2>vltemp){
  122.     delay(100);
  123.   Serial.println("+");
  124.  ;Serial.println(" LIGADO");
  125.     digitalWrite(4,LOW);
  126. delay(100);
  127.   } if(conttemperatura2<vltemp){
  128.     delay(100);
  129.  Serial.println("DESLIGADO");
  130.     digitalWrite(4,HIGH);
  131.     delay(100);
  132.   }
  133.     cont1=1;
  134.   }
  135.  
  136.  
  137.   delay(100);
  138.  
  139.      
  140.  
  141. }
  142. kml
  143. bem10jfx.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment