Hello all
I am working on a project, where I have to control a stepper motor step control with the help of a potentiometer, and arduino ,I have wrote a skech with the help of a friend attached herewith, it is working fine.
now I want to make this thing remote, 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. Earlier one setup I made with servo motor.
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.
Moderators note : used code tags for c
I am working on a project, where I have to control a stepper motor step control with the help of a potentiometer, and arduino ,I have wrote a skech with the help of a friend attached herewith, it is working fine.
now I want to make this thing remote, 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. Earlier one setup I made with servo motor.
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.
C:
#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);
}
Last edited by a moderator: