Point me to the right direction please

Hi all, thanks for reading and thanks in advance for your help
here is the thing I'm a total nooby and like the title says it I need you to point me to the right direction

here in this webpage it says the following: "The microcontroller on the Arduino boards have 512 bytes of EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive)"

I understant the part that says "Arduino boards have 512 bytes" that's a small piece of memory where we can save data to read it later even if we turn the Arduino board off with that been said here what I dont understand: ==>>(How many characters or how many numbers or how long the number it can be)
I'm guessing we can only save a number 0 to 255 meaning the number 255 would be the longest or higher number that we can storage in the EEPROM I got that from the example code below but I don't know if I'm right or not on the other hand I have this other in formation from this website that said the following:

"How many characters is 255 bytes?

Ascii only uses the first 7 bits of each byte, but every character still takes up one byte. 255 bytes would be 255 characters here."

There I see that it says that "255 bytes would be 255 characters here." so what I understand that I can save 255 characters in the EEPROM that would be a long line of characters or numbers

Here is is the point i don't know how many characters I can store in the EEPROM and I need you to tell me the truth.
thanks...

/*

 * EEPROM Write

 *

 * Stores values read from analog input 0 into the EEPROM.

 * These values will stay in the EEPROM when the board is

 * turned off and may be retrieved later by another sketch.

 */

#include <EEPROM.h>

/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
int addr = 0;

void setup() {

  /** Empty setup. **/
}

void loop() {

  /***

    Need to divide by 4 because analog inputs range from

    0 to 1023 and each byte of the EEPROM can only hold a

    value from 0 to 255.

  ***/

  int val = analogRead(0) / 4;

  /***

    Write the value to the appropriate byte of the EEPROM.

    these values will remain there when the board is

    turned off.

  ***/

  EEPROM.write(addr, val);

  /***

    Advance to the next address, when at the end restart at the beginning.

    Larger AVR processors have larger EEPROM sizes, E.g:

    - Arduno Duemilanove: 512b EEPROM storage.

    - Arduino Uno:        1kb EEPROM storage.

    - Arduino Mega:       4kb EEPROM storage.

    Rather than hard-coding the length, you should use the pre-provided length function.

    This will make your code portable to all AVR processors.

  ***/

  addr = addr + 1;

  if (addr == EEPROM.length()) {

    addr = 0;

  }

  /***

    As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an

    EEPROM address is also doable by a bitwise and of the length - 1.

    ++addr &= EEPROM.length() - 1;

  ***/

  delay(100);
} or paste code here

You can store any type of digital data in EEPROM. One EEPROM cell can hold a single byte, or value 0 to 255, but you can combine cells to store long integers, float variables or text.

The 168 processor (some Duemilenove) has only 512bytes of EEPROM.
The 328 (Uno, Nano) has 1024 bytes of EEPROM.

The EEPROM that you are referring to can hold up to 512 bytes of data. Each byte can have a values between 0 and 255 but a combination of bytes can be used to represent any value that you want

Forget the EEPROM for now. On an AVR processor such as the 328 used on a Uno, an int variable (signed or unsigned) uses 2 bytes, a long (signed or unsigned) uses 4 bytes as does a float.

So, when you save the values to EEPROM you need to take that into account

512 bytes of EEPROM can hold 512 byte variables (of course), or 256 int variables or 128 long or float variables. A single character fits in a single byte so you can store 512 characters in a 512 byte EEPROM

The easiest functions to use to save and retrieve values when working with EEPROM are put() and get() as they handle all the nasty complications of putting the bytes that represent larger values into EEPROM and getting them back again

It is still your responsibility to allow for the space needed for the storage. For instance, you cannot put() an int variable into EEPROM positions 0 and 1 because the byte values that they are made up of will overlap at position 1

As AWOL has pointed out an AVR actually has 1024 bytes of EEPROM available so twice as many variables of any type can be held compared to your example 512 byte EEPROM

ok so we have 255 cells meaning we can store 255 characters one in each cell or numbers from 0 to 255 each number on different cells so I can store the number 255 255 times

Am I right on this?? by the way I'm using the Leonardo board

I'm using the Leonardo board how much space do I have?

I don't have a Leonardo, so why don't you check the product page?

Oops! My bad I tought it was 255 bytes intead of 512 byte in the EEPROM
thanks for the explanation tho. cheers!

Good Idea! Cheers!

here it says that the Leonardo board has EEPROM 1 KB (ATmega32u4) which are 1000 bytes. So, I have 1000 cells to work with right?

You have 1 kilobyte, which is a little bit more than 1000 bytes, but if you aim never to exceed 1000 characters you will be safe

What are you actually aiming to store in the EEPROM and how often will it change ?

@UKHeliBob
I'm planning to store lower and Upper case letters, numbers and some characters from a normal English keyboard those characters are characters like: @#$&+()/_!? And so on.

By the way do you think characters like:@#$_&-+()/!? Mete the one byte criteria?

Oh and the letter Ñ and ñ from the Spanish alphabet

It won't chance that often tho I know there is a limit of times for writing in the EEPROM

There are single byte character encodings, and multi-byte. You choose.

The ASCII character set is single byte but uses only 7 bits of the byte.

Thank you so much for pointing that out!

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