Things used in this project

Custom parts and enclosures

fty8akaivo3t4x1_u1xz65PyoT.dxf
Coral Draw Vector
fzuawwrivo3t4wz_PdKRLpvu3f.cdr

Schematics

Schematic 1
Fyjwhj4ivo4a8r7 large omvsql1ikq

Code

code.inoC/C++
/*
 * Simple demo, should work with any driver board
 *
 * Connect STEP, DIR as indicated
 *
 * Copyright (C)2015 Laurentiu Badea
 *
 * This file may be redistributed under the terms of the MIT license.
 * A copy of this license has been included with this distribution in the file LICENSE.
 */
 /*
  * Edited as found from the StepperDriver library by Ernest E Garner
  * Date: 20-Nov-2016
  * 
  * Code Description:
  *    Used to control a basic x/y gantry for the zen table created by Ernest James Garner for Instructables.com
  */
#include <Arduino.h>
#include "BasicStepperDriver.h"

//#define DEBUG

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define X_MOTOR_STEPS 200
#define Y_MOTOR_STEPS 200

//Motor direction to home
//    options 1 (forward)
//            -1(reverse)
#define STEP_FORWARD 1
#define STEP_REVERSE -1
#define X_DIR_HOME STEP_FORWARD
#define Y_DIR_HOME STEP_FORWARD

// All the wires needed for full functionality
#define X_MAX_PIN 6
#define X_HOME_PIN 7 //home pin.
#define X_DIR_PIN 8
#define X_STEP_PIN 9
#define X_ANALOG_PIN A0

#define Y_MAX_PIN 5
#define Y_HOME_PIN 10
#define Y_DIR_PIN 11
#define Y_STEP_PIN 12
#define Y_ANALOG_PIN A2

// Since microstepping is set externally, make sure this matches the selected mode
// 1=full step, 2=half step etc.
#define MICROSTEPS 1

// 2-wire basic config, microstepping is hardwired on the driver
BasicStepperDriver x_stepper(X_MOTOR_STEPS, X_DIR_PIN, X_STEP_PIN, X_HOME_PIN, X_MAX_PIN);
BasicStepperDriver y_stepper(Y_MOTOR_STEPS, Y_DIR_PIN, Y_STEP_PIN, Y_HOME_PIN, Y_MAX_PIN);

int x_position = 0;
int x_analog;
int y_position = 0;
int y_analog;

void setup() {
  #ifdef DEBUG
   Serial.begin(9600);
  #endif
    /*
     * Set target motor RPM.
     * These motors can do up to about 200rpm.
     * Too high will result in a high pitched whine and the motor does not move.
     * 
     * We want these motors to move slowly.
     */
    x_stepper.setRPM(100);
    y_stepper.setRPM(100);    
    
    /*
     * Tell the driver the microstep level we selected.
     * If mismatched, the motor will move at a different RPM than chosen.
     */
    x_stepper.setMicrostep(MICROSTEPS);
    y_stepper.setMicrostep(MICROSTEPS);
}

void loop() {

    /*
     * Moving motor one full revolution using the degree notation
     */
     // 1024/2 = 512
     // 512 - 40 = 472
     // 512 + 40 = 552
     x_analog = analogRead(X_ANALOG_PIN);
     // Joystick pulled to reverse and HOME not pressed
     //if ((x_analog < 472) && (digitalRead(X_HOME_PIN)==HIGH)) {
      if ((x_analog < 472)) {
       x_stepper.move(-40);
      } else if ((x_analog > 552)) {
       x_stepper.move(40);
     }
     #ifdef DEBUG
       Serial.print("X: "); Serial.print(x_analog);  //Serial.print(x_stepper.getDirection());
     #endif
     
     y_analog = analogRead(Y_ANALOG_PIN);
     
     //if ((y_analog < 472) && (digitalRead(Y_HOME_PIN)==HIGH)) {
     if ((y_analog < 472)) {
       y_stepper.move(-40);
      } else if ((y_analog > 552)) {
       y_stepper.move(40);
     }
     #ifdef DEBUG
      Serial.print("  Y: "); Serial.println(y_analog);  //Serial.getDirection(y_stepper.
     #endif

}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Pool Buddy
Intermediate
  • 1,495
  • 11

Work in progress

Monitor and log water quality (pH & ORP) and temperature from everywhere.

Smart Garden
Intermediate
  • 1,992
  • 17

Smart Garden is a plant environmental monitoring system.

Voice Controled Click Lamps
Intermediate
  • 40
  • 2

Work in progress

We have a couple of floor lamps from Ikea. They have two lights in each, and a switch for each light. Let's control them remotely.

WiFi Messenger
Intermediate
  • 1,195
  • 13

Protip

Calling my son from his room using 2 ESP8266 modules, instead of shouting.

IoT Thermometer Using Python
Intermediate
  • 791
  • 8

Full instructions

How to develop a simple but powerful IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

Both Physical & Cloud Cayenne Lights Switch
Intermediate
  • 119
  • 2

The cloud switches are well known, but what happens when the local internet fails and the switch cannot connect to the internet?

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback