Hello,
I’ve used this page to code my arduino in controlling a 42BYG motor:
http://wiki.makeblock.cc/index.php?title=Me_2H_Microstep_Driver
Is it possible to read the current step value?
/*************************************************************************
* File Name : Me_AccelStepper.ino
* Author : Ander
* Updated : Ander
* Version : V0.0.3
* Date : 12/11/2013
* Description : 2 Step Motors
* License : CC-BY-SA 3.0
* Copyright (C) 2011-2013 Hulu Robot Technology Co., Ltd. All right reserved.
* http://www.makeblock.cc/
**************************************************************************/
#include <Makeblock.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 13, 12); // 13-PUL,12-DIR
void setup()
{
stepper.setAcceleration(80000);
stepper.setCurrentPosition(0);
stepper.setMaxSpeed(4000);
}
long current_position;
void loop()
{
current_position = stepper.currentPosition();
if(current_position>=50000){
stepper.moveTo(0);
}
if(current_position<=0){
stepper.moveTo(50000);
}
stepper.run();
}
Thanks!