Go Down

Topic: THERMOMETER (TERMÔMETRO) - Temperature sensor+ LCD 16x2 +leds + max/min (Read 2047 times) previous topic - next topic

lucast8

TERMOMETRO - PROJETO EM ARDUINO QUE MOSTRA A TEMPERATURA AMBIENTE.

screenshot : http://i.tinyuploads.com/s8UADp.jpg

Características:
-3 leds indicadores de temperatura baixa , alta ou boa
-temperaturas maxima e minima, desde que o arduino foi ligado.
-temperatura em fahrenheit
-registra valores no serial monitor

Componentes utilizados:
-microcontrolador arduino uno
-display LCD, 16x2
-jumpers
-potenciometro 10k
-sensor de temperatura lm35
-leds amarelo, verde e vermelho
-3 resistores 330k para os leds.
----------------------------------------------------------------------------
Project that shows the ambient temperature
Features: -
-3 leds indicating wether temperature is low, high or nice
-max/min temperatures, since arduino is on
-temperatures in fahrenheit
-log values on serial monitor

Components i used:
-arduino uno board
-display LCD 16x2
-jumpers
-potenciometer 10k
-temperature sensor LM35
-yellow,green and red led
-three resistors 330k for the leds
------------------------------------------------------------------------
here is how i set on the breadboard : http://i.tinyuploads.com/OVh6Um.jpg

Code: [Select]

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pinoAnalogico = 3;
int pinoPotenciometro = 0;
long valorPotenciometro = 0;
float tempc = 0, tempf=0; // temperature variables (variaveis de temperatura)
float temperature[8]; // variables to make a better precision (variaveis p/ melhor precisao)
int maxi = -100,mini = 100; // to start max/min temperature (p/ comecar max/min temperatura)
int i;


void setup()
{
 Serial.begin(9600);
 lcd.begin(16, 2); //start the display LCD (inicia o display LCD)
 pinMode(7, OUTPUT); //set pin 7 as output for yellow led (define o pino 7 como saída p/ o led amarelo)
 pinMode(8, OUTPUT); //set pin 8 as output for green led (define o pino 7 como saída p/ o led verde)
 pinMode(9, OUTPUT); //set pin 9 as output for red led (define o pino 9 como saída p/ o led vermelho)
}

void loop()
// gets 8 samples of temperature for better precision (retira oito amostras de temperatura p/ melhor precisao)
{
  for(i = 0;i<=7;i++){
   temperature[i] = ( 5.0 * analogRead(pinoAnalogico) * 100.0) / 1024.0;
   tempc = tempc + temperature[i];
   delay(100);
 }
 temps(); //calls function to define temperatures (chama a funcao para definir as temperaturas)
 // prints values on serial monitor (imprime os valores no serial monitor)
 Serial.print(tempc,DEC);
 Serial.print(" Celsius, ");

 Serial.print(tempf,DEC);
 Serial.print(" fahrenheit -> ");

 Serial.print(maxi,DEC);
 Serial.print(" Max, ");
 Serial.print(mini,DEC);
 Serial.println(" Min");

 tempc = 0;
 delay(1000); // 1s delay for update temperature (1s de atraso para atualizar temperatura.)
}


void temps() {
 tempc = tempc/8.0; // calculates final temperature (calcula temperatura final)
 tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit (converte para fahrenheit)

 if(tempc > maxi) {maxi = tempc;} // set max temperature (define temperatura maxima)
 if(tempc < mini) {mini = tempc;} // set min temperature (define temperatura minima)
 write_LCD();
 //here you can set high ,med or low temp values as you wish (aqui vc define os valores de temperatura alta media ou baixa)
 if(tempc < 22)
 {
   digitalWrite(8, LOW);
   digitalWrite(9, LOW);
   digitalWrite(7, HIGH);   // set the yellow LED on (acende led amarelo)
   lcd.setCursor(0, 0);
   lcd.print("Low"); // prints LOW temperature on lcd (imprime temperatura baixa no lcd)
 }
 if(tempc > 27)
 {
   digitalWrite(8, LOW);
   digitalWrite(7, LOW);
   digitalWrite(9, HIGH);   // set the red LED on (acende led vermelho)
   lcd.setCursor(0, 0);
   lcd.print("High"); // prints HIGH temperature on lcd (imprime temperatura alta no lcd)
 }
 if((tempc >= 22) && (tempc <= 27))
 {
   digitalWrite(7, LOW);
   digitalWrite(9, LOW);
   digitalWrite(8, HIGH);   // set the green LED on (acende led verde)
   lcd.setCursor(0, 0);
   lcd.print("Nice"); // prints nice temperature on lcd (imprime temperatura boa no lcd)
 }
}


void write_LCD() // writes on display (escreve no display)
{

 lcd.setCursor(5, 0);
 lcd.print("temperature");
 lcd.setCursor(15, 0);
 lcd.setCursor(0, 1);
 lcd.print(tempc,1); // change tempc for tempf for fahrenheit
 lcd.setCursor(4, 1);
 lcd.print((char)223); //prints degree symbol
 lcd.print("C"); //change to F for fahrenheit
 lcd.setCursor(10, 1);
 lcd.print(maxi);
 lcd.setCursor(12, 1);
  lcd.print("/");
 lcd.print(mini);
 lcd.setCursor(14, 1);
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy