How to solve Error in arduino

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.

The functions fun_0 and fun_1 both have return statements, but the return types are specified as void.

Please reformat the code with code tags </>

2 Likes

1: post the code properly please - in the IDE Edit - copy for forum
then paste into the new comment field

2: comment your code so others (and yourself later) will know what its supposed to do.

Thanks for your answer, I changed tag.now fun code works.

Now you can have fun with your project.

okay

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