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);
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?