EEProm Menu recording

Hello friends, I want to save the temperature setting I set with EEProm in the code below, can you help me?

#include

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

const int LED_RED=10; //Red LED
const int LED_GREEN=11; //Green LED
const int RELAY=12; //Lock Relay or motor

//Key connections with arduino
const int up_key=3;
const int down_key=2;

int SetPoint=30;
//=================================================================
// SETUP
//=================================================================
void setup(){
pinMode(LED_RED,OUTPUT);
pinMode(LED_GREEN,OUTPUT);
pinMode(RELAY,OUTPUT);
pinMode(up_key,INPUT);
pinMode(down_key,INPUT);

//Pull up for setpoint keys
digitalWrite(up_key,HIGH);
digitalWrite(down_key,HIGH);

// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("EL Tronic");
lcd.setCursor(0,1); //Move coursor to second Line
lcd.print("Temp. Controller");
digitalWrite(LED_GREEN,HIGH); //Green LED Off
digitalWrite(LED_RED,LOW); //Red LED On
digitalWrite(RELAY,LOW); //Turn off Relay
delay(2000);
}
//=================================================================
// LOOP
//=================================================================
void loop(){
double Temperature = ((5.0/1024.0) * analogRead(A0)) * 100; //10mV per degree 0.01V/C. Scalling

lcd.setCursor(0,0);
lcd.print("Temperature:"); //Do not display entered keys
lcd.print(Temperature);

//Get user input for setpoints
if(digitalRead(down_key)==LOW)
{
if(SetPoint>0)
{
SetPoint--;
}
}
if(digitalRead(up_key)==LOW)
{
if(SetPoint<150)
{
SetPoint++;
}
}

//Display Set point on LCD
lcd.setCursor(0,1);
lcd.print("Set Point:");
lcd.print(SetPoint);
lcd.print("C ");

//Check Temperature is in limit
if(Temperature > SetPoint)
{
digitalWrite(RELAY,LOW); //Turn off heater
digitalWrite(LED_RED,LOW);
digitalWrite(LED_GREEN,HIGH); //Turn on Green LED
}
else
{
digitalWrite(RELAY,HIGH); //Turn on heater
digitalWrite(LED_GREEN,LOW);
digitalWrite(LED_RED,HIGH); //Turn on RED LED
}

delay(100); //Update at every 100mSeconds
}

You started a topic in the Uncategorised category of the forum whose description is

:warning: DO NOT CREATE TOPICS IN THIS CATEGORY :warning:

Your topic has been moved to the Programming category

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

Have you looked at the examples that come with the EEPROM library ?

Which Arduino board are you using ?

Sorry, I'm new to Arduino, I'm using Arduino uno, can you help me how to add a record to the code here, thank you.

As I said

1 Like

I looked but I couldn't understand much because I'm a newbie. I would be very happy if you could help me. I don't know where to write the code. I would appreciate it if you could write it.

I could write it but you will learn more by writing it yourself

Look at this commented example

#include <EEPROM.h>  //include the library

void setup()
{
    Serial.begin(115200);
    int address = 0;             //EEPROM address to sav the value
    int value;                   //variable to hold a 2 byte int value
    EEPROM.get(address, value);  //get the previous value from EEPROM
    Serial.print("Previous value from EEPROM = ");
    Serial.println(value);
    value++;                     //increment value
    EEPROM.put(address, value);  //put the new value in EEPROM
}

void loop()
{
}

Which part of it do you not understand ?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.