stepper motor with potentiometer controlled by arduino and xbee.

Thread Starter

Manas Bose

Joined Mar 16, 2016
2
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.

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);
}
Moderators note : used code tags for c
 
Last edited by a moderator:

djsfantasi

Joined Apr 11, 2010
6,362
Stepper motors require more than one pin to drive, depending on the type used. Here is a tutorial on using an Arduino to drive a unipolar stepper motor. Note that it uses four pins.
 

mcgyvr

Joined Oct 15, 2009
5,394
What kind of help are you looking for?
You need stepper driver..
You should use google as there are plenty of examples of xbee to xbee communication..

Its simply 2 parts.. get the master/slave talking to pass the pot value..
Then read the pot value on the master and drive the stepper as needed..

IMO.. 99.999% of any Arduino questions/sample files,etc.. are already done on the internet and easily found using google

Here..
This should be sufficient for the xbee communication between the sender and receiver
http://dariushmoshiri.com/Home/Post/11/xbee-communication-between-two-arduinos?returnUrl=/

and there are TONS of stepper examples on the arduino site or just google "arduino stepper potentiometer"..
Combine the 2 and voila..

and a stepper does NOT work like a RC servo...
 

Thread Starter

Manas Bose

Joined Mar 16, 2016
2
Thank u sir,
In this code , the stepper motor, will respond to pot. movement, ie full pot movement = 300 degree rotation of stepper.
 
Top