fiz umas alteraçoes para testar o animal, so começa a dar erros na IDE no loop.
podes ver pf?
alterei todos os print.lcd para mostrar o texto, depois coloco ao certo, mas assim a ver se entro na coisa.
o codigo é este:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int tempAlarmPin = 22; //Buzzer ligado no PIN 22
#define ONE_WIRE_BUS 28 //Sensores ligados no PIN 28
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//Endereços sensores
DeviceAddress insideThermometer = { 0x28, 0x0C, 0x0D, 0xB0, 0x04, 0x00, 0x00, 0x80 };
DeviceAddress outsideThermometer = { 0x28, 0x49, 0x04, 0xB1, 0x04, 0x00, 0x00, 0x62 };
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define butRIGHT 0
#define butUP 1
#define butDOWN 2
#define butLEFT 3
#define butSELECT 4
#define butNONE 5
#define HOME 0
#define MENU_1 1
#define MENU_2 2
#define MENU_3 3
#define MENU_4 4
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return butNONE; // We make this the 1st option for speed reasons since it will be the most likely result
if (adc_key_in < 50) return butRIGHT;
if (adc_key_in < 195) return butUP;
if (adc_key_in < 380) return butDOWN;
if (adc_key_in < 555) return butLEFT;
if (adc_key_in < 790) return butSELECT;
return butNONE; // when all others fail, return this...
}
void setup(void)
{
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);
pinMode(tempAlarmPin, OUTPUT); //Buzzer
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
} else {
lcd.print(tempC);
lcd.print("C");
}
}
void alarm(DeviceAddress deviceAddress){
float tempA = sensors.getTempC(deviceAddress);
if ( (tempA) >= 25) //Temp superior a 23 Graus
{
digitalWrite(tempAlarmPin, HIGH);
delay(500);
digitalWrite(tempAlarmPin, LOW);
}
else if ( (tempA) <= 20) //Temp inferior a 20 graus
{
digitalWrite(tempAlarmPin, HIGH);
delay(500);
digitalWrite(tempAlarmPin, LOW);
}
}
void trataLCD() {
static unsigned char menu = 0; //isto faz com que o menu correcto seja mostrado sempre que a função é chamada.
unsigned int button = analogRead(A0);
//criar funcao que passa o analog read para uma variavel tipo butUP...
//máquina de estados.
switch(menu) {
case HOME: {
if (button == butUP) {
menu = MENU_1;
}
if (button == butDOWN) {
menu = MENU_4;
}
lcd.clear();
lcd.print("hora...");
lcd.setCursor(0,1);
lcd.print("data...");
button = butNONE;
break;
};
case MENU_1: {
if (button == butUP) {
menu++;
}
if (button == butDOWN) {
menu--;
}
lcd.clear();
lcd.print("temp aquario");
button = butNONE;
break;
};
case MENU_2: {
if (button == butUP) {
menu++;
}
if (button == butDOWN) {
menu--;
}
lcd.clear();
lcd.print("temp exterior");
button = butNONE;
break;
};
case MENU_3: {
if (button == butUP) {
menu++;
}
if (button == butDOWN) {
menu--;
}
lcd.clear();
lcd.print("distancia");
button = butNONE;
break;
};
case MENU_4: {
if (button == butUP) {
menu = HOME;
}
if (button == butDOWN) {
menu--;
}
lcd.clear();
lcd.print("temperatura...");
button = butNONE;
break;
}
}
void loop(void)
{
}
na parte do loop nao sei como fazer.