I am using Arduino pro mini controller :using analog pin:A0,A1 to control two stepper motor forward and reverse condition but i am facing one issue in program side .
I give the code. Please anyone give the logic & problem debuging .
#include<EEPROM.h>
#include <Stepper.h>
#define STEPS 32
#define Pot1
#define AnalogSensorPin_0 0
#define AnalogSensorPin_1 1
int present_Val_0 = 0;
int present_Val_1 = 0;
int past_value_0=0;
int past_value_1=0;
int var1,var2;
Stepper stepper_0(STEPS, 6, 8, 7,9);
Stepper stepper_1(STEPS, 2, 4 ,3,5);
void fun_0(int pot_0)
{
int _step,past_value_0=0;
_step=pot_0-past_value_0;
if (_step>past_value_0)
stepper_0.step(_step);
else if (_step<past_value_0)
stepper_0.step(_step);
past_value_0=pot_0;
EEPROM.put(2,past_value_0);
return past_value_0;
}
void fun_1(int pot_1)
{
int _step,past_value_1=0;
_step=pot_1-past_value_1;
if (_step>past_value_1)
stepper_1.step(_step);
else if (_step<past_value_1)
stepper_1.step(_step);
past_value_1=pot_1;
EEPROM.put(3,past_value_1);
return past_value_1;
}
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
stepper_0.setSpeed(200);
stepper_1.setSpeed(200);
pinMode(AnalogSensorPin_0, INPUT); // declar the input pin
pinMode(AnalogSensorPin_1, INPUT);
past_value_0= var1;
past_value_1= var2;
EEPROM.get(2,var1);
EEPROM.get(2,var2);
}
void loop()
{
present_Val_0= map(analogRead(A0),0,1024,0,1024);
present_Val_1 = map(analogRead(A1),0,1024,0,1024);
fun_0(present_Val_0);
fun_1(present_Val_1);
var1=fun_0(present_Val_0);
var2=fun_1(present_Val_1);
}
Now compiling the code but indicating some error but i can't find it.