Hello,
As I told before, I am very new to the Arduino project and I was very impressed by the high complex sketches of people that built an arduino controlled rotary table.
I decided, that it would be nice to have a short program to run my table.
Starting with accellstepper, I think, this is a very helpful program to run a stepper motor with smooth acceleration and decelleration.
Below you will find my short and cheap program, including a remote control for forward and backward steps.
The disadvantage of this program is, that you have to change the steps in the program and it has no step corrections.
Also you must calculate how many steps you need for your division.
But I am sure, that I can improve this program with some mor experience:
#include <AccelStepper.h>
#include "IRremote.h"
int receiver = 2;
/*----- Variables, Pins -----*/
#define STEPPER1_DIR_PIN 9
#define STEPPER1_STEP_PIN 8
/*-----( Declare objects )-----*/
AccelStepper stepper1 (AccelStepper:RIVER,STEPPER1_STEP_PIN,STEPPER1_DIR_PIN);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
irrecv.enableIRIn(); // Start the receiver
stepper1.setMaxSpeed (3000);
stepper1.setAcceleration(1000);
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 0xFF30CF: // VOL+ button pressed
stepper1.moveTo(3200);
while (stepper1.distanceToGo () !=0)
stepper1.run();
stepper1.setCurrentPosition(0);
break;
case 0xFF18E7:
stepper1.moveTo(-3200);
while (stepper1.distanceToGo () !=0)
stepper1.run ();
stepper1.setCurrentPosition(0);
break;}
irrecv.resume(); // receive the next value
digitalWrite(8,LOW);
digitalWrite(9, LOW);
}
}/* --end main loop -- */
As I told before, I am very new to the Arduino project and I was very impressed by the high complex sketches of people that built an arduino controlled rotary table.
I decided, that it would be nice to have a short program to run my table.
Starting with accellstepper, I think, this is a very helpful program to run a stepper motor with smooth acceleration and decelleration.
Below you will find my short and cheap program, including a remote control for forward and backward steps.
The disadvantage of this program is, that you have to change the steps in the program and it has no step corrections.
Also you must calculate how many steps you need for your division.
But I am sure, that I can improve this program with some mor experience:
#include <AccelStepper.h>
#include "IRremote.h"
int receiver = 2;
/*----- Variables, Pins -----*/
#define STEPPER1_DIR_PIN 9
#define STEPPER1_STEP_PIN 8
/*-----( Declare objects )-----*/
AccelStepper stepper1 (AccelStepper:RIVER,STEPPER1_STEP_PIN,STEPPER1_DIR_PIN);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
irrecv.enableIRIn(); // Start the receiver
stepper1.setMaxSpeed (3000);
stepper1.setAcceleration(1000);
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 0xFF30CF: // VOL+ button pressed
stepper1.moveTo(3200);
while (stepper1.distanceToGo () !=0)
stepper1.run();
stepper1.setCurrentPosition(0);
break;
case 0xFF18E7:
stepper1.moveTo(-3200);
while (stepper1.distanceToGo () !=0)
stepper1.run ();
stepper1.setCurrentPosition(0);
break;}
irrecv.resume(); // receive the next value
digitalWrite(8,LOW);
digitalWrite(9, LOW);
}
}/* --end main loop -- */