Hello, i am making little project which is based on Arduino nano. There is analog pressure sensor, oled screen, rotary encoder and relay. Via encoder is set target on which is relay turn on. All is working fine. But i need little help. My IQ are not too high for understand how to work with eeprom. I need to save target value via button (2s press) on encoder, store it and set it after powering the arduino. Is there anyone able to help me? Sorry for my english.
Yes this is exactly what i need. Long press to save actual target value seted via encoder to eeprom. And after load this value and set it after every start but so that it can still be adjustable.
It appears that you already have code in the loop() to adjust the variable target.
It detects changes to the encoder position and updates target.
A simpler way is simply to retain the original code but with the addition that, at the end of a session, the target value is saved to EEPROM (if it has changed). At the beginning of the next session, the value is retrieved from the EEPROM. Would that work for you?
It is also possible to do it with a long button press to initiate the "configuration" of the value target if that is what you prefer. You then maybe have to consider a timeout if someone initiates the update of target, but does not finish it.