Pages: [1]   Go Down
Author Topic: Writing to External Eeprom From Serial Monitor  (Read 658 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone,
I am using a arduino Mega 2560 and am attempting to write some data from the serial monitor to a 24lc256 Eeprom. I cannot tell whether I have written the data correctly, or whether my code to read the data is the problem. I have two separate sketches, one for writing data, and one for reading. When I try to write data, everything performs as expected, but when I try to read the data I get "myyyyyyyyyyyyyyyyyyyyyyyyyyyy" except the y's have two dots on top of them. I tried writing the phrase "Hi, I am an Eeprom" to the 24lc256 so something is obviously going wrong.

For some reason, this thing refuses to let me paste my code, so it is attached. First sketch is for writing, and the second for reading.
Help is greatly appreciated!

-confused hobbyist

* Eeprom24LC256.ino (0.62 KB - downloaded 7 times.)
* ReadEeprom24LC256.ino (0.61 KB - downloaded 5 times.)
Logged

Offline Offline
Edison Member
*
Karma: 35
Posts: 1429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the writing routine you declare writeaddress as a global variable. Then you pass it as an argument into the write routine and inside that routine writeaddress is a different local variable. So, when the write routine increments writeaddress it is incrementing the local copy, not the global one which always stays at zero.
You have the same problem in the read routine as well. Don't pass those addresses as arguments and the code will work.

Pete
Logged

Where are the Nick Gammons of yesteryear?

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you so much! Now it makes sense.
Logged

Pages: [1]   Go Up
Jump to: