User Tools

Site Tools


workshops:arduino_to_the_next_level:remembering_state

Introduction

Your Arduino has some Random Access Memory (RAM) that you can use for storing and reading variables. However there is a limitation, if the power to the Arduino is turned off anything stored in RAM is lost. Often this doesn't matter but sometimes it's very important. Take for example a person counter in a art gallery. It's important to keep an accurate count of the total people that have visited the gallery, it would be unacceptable if the counter reset to zero every time the Ardunio power was switched off or reset.

Fortunately there is another area of memory on an Arduino called EEPROM (Electrically Erasable Programmable Read-Only Memory). This can be written to by your Arduino program and will be saved when the Arduino is switched off or reset.

There are two EEPROM functions that you use, EEPROM.write and EEPROM.read

  • First make sure the EEPROM on your adruino is clear by following this tutorial
challenge_yourself.jpg Easier
(1) Connect up a push switch to the Arduino and have it output the number of time the switch has been pushed. You can either display this on the LCD display or onto your laptop serial connection using Serial.println Unplug the power from your Arduino, what happens to the count?

Intermediate
(2) Modify your program to save the count to EEPROM, so that it is saved when the power goes off and read when the power goes back on. Can you think of any limitations of your solution?

Tips

The EEPROM in your Arduino is rated by the manufacturer for 100,000 writes, so be aware that you can't write too often.

In reality it can last for more than that to over 1,000,000 writes.

workshops/arduino_to_the_next_level/remembering_state.txt · Last modified: 2017-04-11 11:23 by Simon

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki