Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:32:04+00:00 2026-06-17T18:32:04+00:00

I am used to programming PC’s and smartphones using high level languages, microcontrollers are

  • 0

I am used to programming PC’s and smartphones using high level languages, microcontrollers are a new territory for me. Are they somehow different, more untrustworthy, requiring different techniques? Here is bit of code to write and read to EEPROM running on a Arduino Mega: (there is an Ethernet Shield attached, not used here)

#include <EEPROM.h>
int addr = 0;
int val;
byte value;
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  val = 9;
  EEPROM.write(addr, val);
  delay(500);
  addr = addr + 1;
  if (addr == 20) addr = 0;
  value = EEPROM.read(addr);
  Serial.print(addr);
  Serial.print("\t");
  Serial.print(value);
  Serial.println();  
}

Heres what comes out:

1   91
2   91
3   9
4   9
5   9
6   9
7   9
8   9
9   9
10  9
11  9
12  202
13  202
14  202
15  202
16  202
17  202
18  202
19  202
0   9
1   89
2   91
3   9
4   9
5   9
6   9
7   9
8   9
9   9
10  9
11  9
12  9
13  9
14  9
15  9
16  9

…..
In general address 1 and 2 are always flaky and it takes two writes to change memory locations above ~10.

I can switch out another board and still get similar oddities.

How can I adapt my programming to this seemingly flaky performance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:32:05+00:00Added an answer on June 17, 2026 at 6:32 pm

    Simply enough, your code is wrong.

    Logically step through it. You are writing to an EEPROM at address addr. You then wait 500ms, increment addr, and then read from the new addr. The addr you read from is therefore not the addr you write to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a general list of what different programming languages are used to solve
Which widely used programming languages were designed ground-up with Unicode support? A lot of
In most programming languages I've used, when debugging, when I hit a breakpoint, I
I succesfully used a validator more than once,but after some programming my validators are
I've got a friend trying to learn php (they've never used a programming/scripting language
I have used OO programming languages and techniques years ago (primarily on C++) but
I've done a lot of server-side HTML programming and used a number of different
I have been asked to compare the programming models used by two different OSs
does Meteor offer any escaping shortcut like the backslash used in some programming languages?
I am used to programming in the previous versions of iOS, and new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.