Advertisement
Fabio575

Controle de Temperatura com Arduino NANO

Aug 16th, 2020
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. #include <LiquidCrystal.h>                                  //inclui LCD  
  2. #include "max6675.h"                                        //inclui MAX6675
  3.  
  4. int thermoDO = 11;
  5. int thermoCS = 12;
  6. int thermoCLK = 6;
  7.  
  8. #define rele  13
  9.  
  10. MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);        //Cria objeto para termopar e MAX6675
  11.  
  12. // --- Hardware do LCD ---
  13. LiquidCrystal lcd (8,                                       //RS no digital 8
  14.                    7,                                       //EN no digital 7
  15.                    5,                                       //D4 no digital 5
  16.                    4,                                       //D5 no digital 4
  17.                    3,                                       //D6 no digital 3
  18.                    2);                                      //D7 no digital 2
  19.  
  20.  
  21. int minhaTemp = 0;
  22. //-------------------------------------------------------------------------
  23. void setup() {
  24.  
  25.   lcd.begin(16, 2);                                         //inicializa LCD 16x2
  26.  
  27.   Serial.begin(9600);
  28.   pinMode(rele, OUTPUT);
  29.   Serial.println("MAX6675");
  30.   delay(500);
  31. }
  32. //-------------------------------------------------------------------------
  33. void loop() {
  34.   //Limpa a tela
  35.   lcd.clear();                                              //Limpa o LCD
  36.   lcd.setCursor(3, 0);                                      //Posiciona o cursor na coluna 3, linha 0;
  37.   lcd.print("Temperatura");                                 //Envia o texto entre aspas para o LCD
  38.   lcd.setCursor(4,2);    
  39.   lcd.print("C = ");
  40.   lcd.setCursor(9,2);    
  41.   lcd.print(thermocouple.readCelsius());                    //Imprime temperatura em graus Celsius no LCD
  42.  
  43.   delay(5000);
  44.  
  45.   Serial.print("C = ");                                     //Imprime temperatura em graus Celsius no Terminal
  46.   minhaTemp = thermocouple.readCelsius();
  47.   Serial.println(minhaTemp);
  48.   if (minhaTemp < 133)
  49.     digitalWrite(rele, HIGH);
  50.   if (minhaTemp > 135)
  51.     digitalWrite(rele, LOW);
  52.   delay(1000);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement