read memory() / update memory() please help

Hello guys, I’ve been dealing with this code for over 3 weeks now, (from class) professor is not very helpful at all, I’ve asked him several times and the code is still not working. I think I finally fixed what was wrong before as it lets me upload it but I am missing the end of the code under “Void read_memory() " it is supposed to be filled by student but I am not too clear on what I am supposed to add there. I looked at this " read, write and update memory” in forums but I am still confused, can someone please help me?
In addition I understand this is just a program for light to flash and delay after each time the button is pressed but that’s all I know, can someone also explain what the read and write and update does to the light? or button? or what this code in general does ?
I appreciate all the help,
I am attaching the file here, and what I need help with is the last 10 lines right below " read_memory() "

Thanks,

Maykel

lab2.ino (2.11 KB)

lab 2 timers.txt (2.21 KB)

What memory needs to be read? EEPROM?
What value(s) will be read from memory, and what will be done with those values?

You don't present enough information for us to help you, I'm afraid.

professor is not very helpful at all

Maybe because it is NOT has assignment to do. Maybe YOU should have been paying attention in class. I get so tired of students coming in here whining that it is the instructors fault that they haven't made any attempt to learn. Well, guess what? It isn't the instructor's fault.

I am not sure how to reply to a specific reply as I am new to this site and forum.
to answer the first question I think it is eeprom.h library. Unfortunately the professor hasn’t given more instructions for this, which is why I am very confused.

To answer the second question which say I should’ve paid attention more in class. I completely understand, and yes there are A LOT of people who do not pay attention in my class, I have to say there are probably 3 out of 28 students in that class who pay attention, me being one of them. This assignment was given over a month ago, maybe more, and I’ve been battling with it from first day. Last week in class when I demanded the professor to try and help me with it, that’s when he mentioned the code needed "EEPROM.h " in it, which he’s NEVER taught us, not only that but in the paper he gave us, it was not included either. I’ve taken a picture of what he gave us to do. He literally just handed us the paper and told us this is a code for a timer and it reads from memory, but he seriously did not explain how it worked. Just told us to set up the arduino using the schematic in the paper and to use the code given and fill in the parts where it says “to be filled by student”
Last week I also asked another guy one who I think pays attention in class and asked him if he could explain it to me, and he partially did, but still missing the last part and he said he just ignored that part. Professor never really actually checks the written reports, he just checks them and that’s it. I do want to understand what it is that it’s missing and what it does instead of just presenting a partial report which is why I came to this forum, but it seems the code might missing more than I thought. So perhaps I should just write it incomplete. I appreciate the replies though. I’ve attached what the paper the professor handed out.

That last line on the back says he wants it to wake (wrong choice of words but whatever) into the same state it was in when power is restored or the reset button is pushed. So it sounds like you need to save your state variable to EEPROM so you can recover it after a power cycle. That shouldn't be very hard. Have you looked at any of the EEPROM examples?

OK. If you were one of the people paying attention, then I apologize for my rant. Too many people come here expecting us to do there homework for them.

There was code provided. It seems like all you need to do is determine some way to persist the state (of something; it wasn't clear what state) so that when the power is lost, the state can be recovered.

EEPROM is one way. There are really very few functions for storing data in, or getting data from, EEPROM, since EEPROM is byte-sized storage. That makes saving and retrieving data pretty simple, if the data to be stored is byte-sized. State certainly seems to be, since I can't imagine more than 256 states.

If you have difficulty determining what to save, or how to use read() or write() (or get() or put()), feel free to post your attempt, and explain what did, or did not, work.

In spite of our sometimes cantankerous moods, we ARE here to help.

Delta_G:
That last line on the back says he wants it to wake (wrong choice of words but whatever) into the same state it was in when power is restored or the reset button is pushed. So it sounds like you need to save your state variable to EEPROM so you can recover it after a power cycle. That shouldn't be very hard. Have you looked at any of the EEPROM examples?

I agree. Now that the professor has mentioned "EEPROM.h", and seeing his choice of words on the paper, the "state" variable is clearly what he expects to be saved then restored on power-up. Although it's an int, since it never holds a value larger than 3, it could be saved as a byte, too. Too easy. :slight_smile:

Thank you all for the help, I was trying some code I saw online and it allowed me to upload it in arduino, but my light stays on at all times :stuck_out_tongue: when I set it up. Unfortunately there's not much time left of school and I will just have to present this incomplete, however I will try and figure out on my own once I have some down time and I don't need to rush to present a report. ( I have other classes I need to focus as well) I really like arduino and coding, so I know I'll come back and get it working at some point :slight_smile:
Thank you again :slight_smile: