How to store EEPROM 10bit analog data

hai everyone
I am yugenthar, using arduino pro-mini controller
my project control stepper motor using analog value forward and reverse controlling .
I have facing one problem ,example:motor stating point 0 to 5 but reset the controller again stating 0 to 5 not storing last value .i have attach my code .please anyone give the solution.
#include<EEPROM.h>
#include <Stepper.h>

#define STEPS 32

int AnalogSensorPin = A0;

int _step;

int past_valueval = 0;

int potVal = 0;

Stepper stepper(STEPS, 6, 8, 7,9);

void setup() {

// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
stepper.setSpeed(200);
pinMode(AnalogSensorPin, INPUT); // declar the input pin

Read=EEPROM.read(2);

}

void loop() {
uint8_t range[2];

potVal = map(analogRead(A0),0,1024,0,1024);

_step=potVal-past_value;

if (_step>past_value)

stepper.step(_step);

else if (_step<past_value)

stepper.step(_step);

past_value= potVal; //storing last value
EEPROM.write(2,past_value);

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

past_value is an int
ints take 2 bytes of storage
EEPROM.write() saves a single byte
EEPROM.read() reads a single byte

Can you see a problem ?

Take a look at EEPROM.put() and EEPROM.get() to write/read data of any type

Actually you are facing multiple problems.

Your code does not compile... there are a number of basic errors. Have you tried to compile the program? highlighted the errors? and tried to fix them?

Thanks sir ,I have change little bit of code and problem is solved

Thanks sir
code is done i have using eeprom.put/eeprom.get function

To help anyone with the same problem please post you fixed code, using code tags when you do

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