Hello
I have wrote a skech with the help of a friend attached herewith, it is working fine.
stepper motor should respond to the potentiometer movement ie. it
should rotate 0-360 degrees and 360-0 degrees, one single rotation
according to potentiometer movement.
Now I want to make this thing wireless, sir I want to use 2 arduino and 2 xbee, on sending side a arduino,
xbee, and a potentiometer will be there.
On receiving side a arduino, xbee and a stepper motor will be there.
I and my friend don't have adequate knowledge of c ++, I hereby request u to kindly help
In the coding, or at least if u can throw some light on it.
Hope to be favored please
Thanking you
Manas
#include <Stepper.h>
int current_position = 0;
const char direction_pin = 2;
const char step_pin = 3;
const char pot_pin = 1; //analog input 1
void setup()
{
pinMode(direction_pin, OUTPUT);
pinMode(step_pin, OUTPUT);
pinMode(pot_pin, INPUT);
}
void loop()
{
int readvalue = analogRead(pot_pin);
readvalue = map(readvalue,0,1023,0,1151);
if (readvalue > current_position)
{
step_motor_forward();
current_position += 1;
}
else if (readvalue < current_position)
{
step_motor_back();
current_position -= 1;
}
}//end of loop
void step_motor_forward()
{
digitalWrite(direction_pin, LOW);
digitalWrite(step_pin, HIGH);
digitalWrite(step_pin, LOW);
}
void step_motor_back()
{
digitalWrite(direction_pin, HIGH);
digitalWrite(step_pin, HIGH);
digitalWrite(step_pin, LOW);
}