needing help to develop a menu using LCD Keypad shield ..

help me… In this program, therefore, using three sensors, DS18B20 and two relays, I need to make a menu, which regulates two levels of temperature, low and high on my LCD. The code is below.

// Author: Fabio costa

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Sensor data wire in the Arduino
#define ONE_WIRE_BUS1 3
#define ONE_WIRE_BUS2 2

// Set up a one-way instance to communicate with any OneWire device
OneWire oneWire_int(ONE_WIRE_BUS1);
OneWire oneWire_out(ONE_WIRE_BUS2);

// initialize the library with the pin numbers of the interface
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// Pass our oneWire reference for Dallas temperature.
DallasTemperature sensors_1(&oneWire_int);
DallasTemperature sensors_2(&oneWire_out);

// arrays to maintain device addresses
DeviceAddress sensor1;
DeviceAddress sensor2;

int relay1 = A1; // pin of the first relay 1
int relay2 = A2; // pin of the first relay 2

byte setpoint1 = 31; // high temperature to switch on the relays
byte setpoint2 = 30; // temperature to lower relays

void setup(void)

{
pinMode(relay1, OUTPUT); // relay pin 1
pinMode(relay2, OUTPUT); // relay pin 2

lcd.begin(16, 2);

// start serial port
Serial.begin(9600);
Serial.println(“Localizando sensores DS18B20…”);

// Start the library
sensors_1.begin();
sensors_2.begin();

// find devices on the bus
Serial.print(“Localizando dispositivos…”);
Serial.print(“Encontrado”);
Serial.print(sensors_1.getDeviceCount(), DEC);
Serial.print(sensors_2.getDeviceCount(), DEC);
Serial.println(" dispositivos.");

// report parasite energy requirements
Serial.print("Poder parasita é: ");
if (sensors_1.isParasitePowerMode()) Serial.println(“ON”);
if (sensors_2.isParasitePowerMode()) Serial.println(“ON”);
else Serial.println(“OFF”);

if (!sensors_1.getAddress(sensor1, 0)) Serial.println(“Não é possível encontrar o endereço do dispositivo 0”);
if (!sensors_2.getAddress(sensor2, 0)) Serial.println(“Não é possível encontrar o endereço do dispositivo 0”);

// show the addresses we found
Serial.print("Endereço do dispositivo 0: ");
printAddress(sensor1);
printAddress(sensor2);
Serial.println();

// sets the resolution to 9 bits
Serial.print("Resolução do dispositivo 0: ");
Serial.print(sensors_1.getResolution(sensor1), DEC);
Serial.print(sensors_2.getResolution(sensor2), DEC);
Serial.println();

}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 7; i++)
{
// reset address if necessary
if (deviceAddress < 16) Serial.print(“0”);
_ Serial.print(deviceAddress*, HEX);_
_
}_
_
}_
_
// function to print the temperature of a device*_
void printTemperature(DeviceAddress deviceAddress)
{

// Sensor read temperature
float tempC1 = sensors_1.getTempC(deviceAddress);
float tempC2 = sensors_2.getTempC(deviceAddress);
* Serial.print("Temp C: ");*
* Serial.print(tempC1);*
* Serial.print(tempC2);*
* delay(2000);*
}
// function to print the resolution of a device
void printResolution(DeviceAddress deviceAddress)
{
* Serial.print("Resolução: ");*
* Serial.print(sensors_1.getResolution(deviceAddress));
Serial.print(sensors_2.getResolution(deviceAddress));
_
Serial.println();_
_
}_
_
// main function to print information about a device*_
void printData(DeviceAddress deviceAddress)
{
* Serial.print("Endereço do dispositivo: ");*
* printAddress(deviceAddress);*
* Serial.print(" ");*
* printTemperature(deviceAddress);*
* Serial.println();*
}
// Generic function for triggering any relay
* void termostato(int pin1,int pin2, int temp1, int temp2) {// put the pin and the desired temperature*
* if ( sensors_1.getTempC(sensor1) >= temp1) // when the temperature is higher or equal to the desired value, turn on the relay*
* {*
* delay(1000); // prevents the relay from blinking when the temperature is too close to the desired*
* digitalWrite(pin1,LOW);*
* Serial.println(“Off”);*
* }*
* else if (sensors_1.getTempC(sensor1) <= temp2) // when the temperature is less than or equal to the desired value, turn ON the relays*
* {*
* delay (1000);*
* digitalWrite(pin1,HIGH);*
* Serial.println(“On”);*
* }*
* if ( sensors_2.getTempC(sensor2) >= temp1) // when the temperature is higher or equal to the desired value, turn on the relay*

* {*
* delay(1000); // prevents the relay from blinking when the temperature is too close to the desired*
* digitalWrite(pin2,LOW);*
* Serial.println(“Off”);*
* }*

* else if (sensors_2.getTempC(sensor2) <= temp2) // when the temperature is less than or equal to the desired value, turn ON the relays*
* {*

* delay (1000);*
* digitalWrite(pin2, HIGH);*
* Serial.println(“On”);*
* }*
}
void loop(void)
{
// call sensors.request Temperatures () to emit a global temperature
* sensors_1.requestTemperatures();
sensors_2.requestTemperatures();
_
// prints device information*_
* Serial.println(sensors_1.getTempC(sensor1));
Serial.println(sensors_2.getTempC(sensor2));*

// Display data on LCD
* lcd.clear();*
// Sensor 1
* lcd.setCursor(0,0);*
* lcd.print("Temp1: ");*
* //Simbolo grau*
* lcd.write(223);*
* lcd.print(“C”);*
* lcd.setCursor(7,0);*
* lcd.print(sensors_1.getTempC(sensor1));
_
lcd.setCursor(0,1);_
_
//Sensor 2*_
* lcd.print("Temp2: ");*
* //Simbolo grau*
* lcd.write(223);*
* lcd.print(“C”);*
* lcd.setCursor(7,1);*
* lcd.print(sensors_2.getTempC(sensor2));
_
termostato(relay1,relay2, setpoint1, setpoint2);_
_
delay(500);_
_
}*_

Wow, does the IDE also shows your code in italics?

Read How to use this forum - please read, specifically pount 7.

Next modify your post.

For the menu, you do not state what you're stuck with, so it's difficult to help. Is this one of those shields with 5 buttons (and a reset button)?

I tried to do here now appeared a problem, this project is to monitor temperature, you control the temperature by the buttons on the lcd keypad shield. it shows the temperature recorded on the LCD, and the actual temperature, when the temperature goes down to the desired value, it triggers the relay, if the temperature goes up a bit it turns off, and it shows whether the motor is turning on or off the screen …

the problem is that the sensor is not reading the actual temperature, it just keeps showing me (-127 degrees) I already put a 4.7k

#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

//States for the menu.
int currentMenuItem = 0;
int lastState = 0;
int motorspeed = 11;
int minspeed = 10;
int maxspeed = 60;
boolean Mainstate = false;
#define RELAY_ON 0
#define RELAY_OFF 1
int state1;
int state2;
int Relay1Pin = 11;//Cooling system Relay
int Relay2Pin = 12;//Heating system Relay
float toptemp = 60.00;
float maxtemp = 28.00;// If max temp is exceeded relays are switched
float mintemp = 20.00;

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//0x28, 0xFD, 0x69, 0x15, 0x06, 0x00, 0x00, 0xAC
DeviceAddress Probe01;
byte Thermo[8] = //icon for Thermometer
{
B00100,
B01010,
B01010,
B01110,
B01110,
B11111,
B11111,
B01110
};

byte Arrow[8] = { 8,12,10,9,10,12,8};
void setup() {
digitalWrite(Relay1Pin, RELAY_OFF);
digitalWrite(Relay2Pin, RELAY_OFF);
pinMode(Relay1Pin, OUTPUT);
pinMode(Relay2Pin, OUTPUT);
//Serial.begin(9600);
delay(1000);
//start reading
lcd.createChar(1,Thermo);
lcd.createChar(2,Arrow);
sensors.begin();
sensors.setResolution(Probe01, 10);
//setup the LCD
lcd.begin(16, 2); // start the library

}
/-------------------------------------------------------------(MAIN LOOP)----------------------------------------------------------/
void loop() {

statecheck();
if (Mainstate == 0){//If Menu buttons are not pushed read temp and display
tempcall();
}
else{
//digitalWrite(Relay1Pin, RELAY_OFF); // turns of heater and stirrer when menu is accessed
//digitalWrite(Relay2Pin, RELAY_OFF);
mainMenu();//If menu buttons are pushed pass state into mainmenu function

}
}

/------------------------------------------------( Declare User-written Functions )-----------------------------------------------/
boolean statecheck(){// Checks if menu buttons pressed to initiate the menu display
//Refresh the button pressed.
//State = 0 every loop cycle.
//int state;
//state = 0;
int x = analogRead (0);
//Check analog values from LCD Keypad Shield
if (x > 0 && x < 90) {
//Right
} else if (x > 91 && x < 250) {
//Up
Mainstate = true;
} else if (x > 251 && x < 400){
//Down
Mainstate = true;
} else if (x > 400 && x < 600){
//Left
Mainstate = true;
} else if (x > 600 && x < 640){
//Select
Mainstate = true;
}

return Mainstate;
}

void tempcall(){
//read temperature and output via LCD
sensors.requestTemperatures();
lcd.clear();
lcd.setCursor(0,0);
lcd.write(byte(1));
lcd.setCursor(2,0);
//lcd.print(sensors.getTempCByIndex(0));
float TEMP = sensors.getTempC(Probe01);
lcd.print(TEMP,1);//Second value is number of sig figs
lcd.setCursor(6,0);
lcd.print((char)223);
lcd.print(“C”);
lcd.setCursor(0,1);//9,0
lcd.write(byte(2));
lcd.setCursor(2,1);//9,0
lcd.print(maxtemp,1);
lcd.print((char)223);
lcd.print(“C”);
Temperatureexceed(Probe01);//Turn on or off relays is certain temperature conditions are met

}
void Temperatureexceed(DeviceAddress deviceAddress)// Controls relays based on temperature readings
{
//float currenttemp = sensors.getTempCByIndex(0);
float currenttemp = sensors.getTempC(deviceAddress);

if(currenttemp <= maxtemp){
state1 = RELAY_ON;//OFF for cooling system(If Stirrer instead always on)
state2 = RELAY_ON;//ON for heating system

lcd.setCursor(10,0);//1,1
lcd.print(“HEATER”);
lcd.setCursor(12,1);//1,1
lcd.print(“ON”);
}
else{
state1 = RELAY_ON;// OFF for cooling system
state2 = RELAY_OFF;//OFF for heating system
lcd.setCursor(10,0);//1,1
lcd.print(“HEATER”);
lcd.setCursor(12,1);//1,1
lcd.print(“OFF”);
}
digitalWrite(Relay1Pin, state1);
digitalWrite(Relay2Pin, state2);
}

boolean mainMenu() {// Sets up main menu
//Refresh the button pressed.
//State = 0 every loop cycle.
int state;
//boolean mainstate;
state = 0;
//Set the Row 0, Col 0 position.
lcd.setCursor(0,0);
//If we are out of bounds on th menu then reset it.
if (currentMenuItem <= -1) {
currentMenuItem = 4;
displayMenu(currentMenuItem);
}
if (currentMenuItem >= 5){
currentMenuItem = 0;
displayMenu(currentMenuItem);
}

state = xcheck();//Checks which button was pressed
//If we have changed Index, saves re-draws.
if (state != lastState) {
if (state == 1) {
//If Up
currentMenuItem = currentMenuItem - 1;
displayMenu(currentMenuItem);
} else if (state == 2) {
//If Down
currentMenuItem = currentMenuItem + 1;
displayMenu(currentMenuItem);
} else if (state == 3) {
//If Left
Mainstate = false;
tempcall();// Needs to go back to main loop
}else if (state == 4) {
//If Selected
selectMenu(currentMenuItem);
currentMenuItem = 0;
}
//Save the last State to compare.
lastState = state;
}

//Small delay
delay(5);

return Mainstate;
}

//Display Menu Option based on Index.
void displayMenu(int x) {// Prints menu options
switch (x) {
case 1:
clearPrintTitle();
lcd.print (“Incr Max Temp”);
break;
case 2:
clearPrintTitle();
lcd.print (“Decr Max Temp”);
break;
case 3:
clearPrintTitle();
lcd.print (“Inc Motor Speed”);
break;
case 4:
clearPrintTitle();
lcd.print (“Decr Motor Speed”);
break;
}
}

//Print a basic header on Row 1.
void clearPrintTitle() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("CONFIGURE ");
lcd.setCursor(0,1);
}

//Show the selection on Screen.
void selectMenu(int x) {// Lowest menu level
int statespeed;
int statetemp;
switch (x) {
case 1:
lcd.clear();
lcd.setCursor(0,0);
lcd.print (“Max Temperature”);
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Temp = “);
//Call the function that belongs to Option 2
incrmaxtemp();
lcd.setCursor(0,1);
delay(1000);
break;
case 2:
lcd.clear();
lcd.setCursor(0,0);
lcd.print (“Max Temperature”);
lcd.setCursor(0,1);
lcd.print(” ");
lcd.setCursor(0,1);
lcd.print("Temp = ");
//Call the function that belongs to Option 2
decrmaxtemp();
lcd.setCursor(0,1);
delay(1000);
break;

}

}
int xcheck(){//Checks which button is pushed when changing temp
int x = analogRead (0);
int state = 0;
//Check analog values from LCD Keypad Shield
if (x > 0 && x < 90) {
//Right
} else if (x > 91 && x < 250) {
//Up
state = 1;
} else if (x > 251 && x < 400){
//Down
state = 2;
} else if (x > 400 && x < 600){
//Left
state = 3;
} else if (x > 600 && x < 640){
//Select
state = 4;
}

return state;
}

int incrmaxtemp(){//Incrementally changes max temperature
if (maxtemp+1 > toptemp){
maxtemp = toptemp - 1;
}
maxtemp = maxtemp + 1;
lcd.setCursor(7,1);
lcd.print(maxtemp);
lcd.print((char)223);
lcd.print("C ");

}

int decrmaxtemp(){//Incrementally changes max temperature
if (maxtemp-1 < mintemp){
maxtemp = mintemp + 1;
}
maxtemp = maxtemp - 1;
lcd.setCursor(7,1);
lcd.print(maxtemp);
lcd.print((char)223);
lcd.print("C ");

}

Carefully re-read post #1.

Have you written a sketch that only reads one sensor and displays the data?

he is showing the giving the buttons are working properly, but he is not giving me the actual reading of the sensor Ds18B20, just did not test the relay if it is correctly right ..

"I know little of programming, but I intend to go deeper and learn more, this project that I am trying to do and to implement in the fish nursery" ..

"I want to put at least 6 reles, with an interval to not trigger everything at once." It will have a Bluetooth module so you can do the monitoring through the application that you are trying to develop. the possibility of being able to start the engine when I want ... billing I will take this module Bluetooth and put (wi-fi) to be able to do the monitoring from far