Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <OneWire.h>
- #include <DallasTemperature.h>
- // sensor temperatura port 2
- #define ONE_WIRE_BUS 2
- //rele ligar/desligar ventilador/ar
- #define ObjVent 4
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensor(&oneWire);
- //referencia para temperatura final
- float conttemperatura1=0;
- int conttemperatura2=0;
- int cont1=0;
- int pin_modeVent=4;
- int vltemp=29;
- void setup(void)
- {
- digitalWrite(4,HIGH);
- Serial.begin(9600);
- delay(145);
- Serial.println("Dallas Temperature library");
- sensor.begin();
- pinMode(4,OUTPUT);
- }
- void loop(void)
- {
- //conaando o loop
- cont1= cont1+1;
- delay(100);
- //requisiçao do sensor
- sensor.requestTemperatures();
- //temperatura atural
- delay(100);
- //float dooble int
- conttemperatura1=sensor.getTempCByIndex(0);
- conttemperatura2=conttemperatura1;
- if(Serial.available()){
- char caracter=Serial.read();
- if(caracter=='A'){
- Serial.println("LIGADO");
- digitalWrite(4,LOW);
- }
- if(caracter=='B'){
- Serial.println("DESLIGADO");
- digitalWrite(4,HIGH);
- }
- if(caracter=='X'){
- delay( 100);
- vltemp=vltemp+1;
- delay(100);
- Serial.print(" almentando temperatura");
- Serial.println( vltemp);
- delay(100);
- }
- if(caracter=='Y'){
- delay(100);
- vltemp=vltemp-1;
- delay(100);
- Serial.print(" Diminuindo temperatura");
- Serial.println( vltemp);
- delay(100);
- }
- if(caracter=='K'){//padrao modifique
- vltemp=25;
- }
- if(caracter=='k'){
- vltemp=25;
- }
- }
- if(cont1==1){
- Serial.println(conttemperatura1);
- delay(100);
- if(conttemperatura1>vltemp){
- Serial.println("+");
- }delay(100);
- if(conttemperatura1<vltemp){
- delay(100);
- Serial.println("-");
- }delay(100);
- }
- if(cont1==3){
- delay(100);
- Serial.println(conttemperatura2);
- delay(100);
- if(conttemperatura2>vltemp){
- delay(100);
- Serial.println("+");
- ;Serial.println(" LIGADO");
- digitalWrite(4,LOW);
- delay(100);
- } if(conttemperatura2<vltemp){
- delay(100);
- Serial.println("DESLIGADO");
- digitalWrite(4,HIGH);
- delay(100);
- }
- cont1=1;
- }
- delay(100);
- }
- kml
- bem10jfx.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment