1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Audrino Sketch to run Steppers

Discussion in 'SimTools compatible interfaces' started by Harry King, Dec 31, 2016.

  1. Harry King

    Harry King Member

    Joined:
    Apr 6, 2016
    Messages:
    43
    Balance:
    224Coins
    Ratings:
    +4 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    /*
    Stepper Motor Control - speed control

    This program drives a unipolar or bipolar stepper motor.
    The motor is attached to digital pins 8 - 11 of the Arduino.
    A potentiometer is connected to analog input 0.

    The motor will rotate in a clockwise direction. The higher the potentiometer value,
    the faster the motor speed. Because setSpeed() sets the delay between steps,
    you may notice the motor is less responsive to changes in the sensor value at
    low speeds.

    Created 30 Nov. 2009
    Modified 28 Oct 2010
    by Tom Igoe

    */

    #include <Stepper.h>

    const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
    // for your motor


    // initialize the stepper library on pins 8 through 11:
    Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

    int stepCount = 0; // number of steps the motor has taken

    void setup() {
    // nothing to do inside the setup
    }

    void loop() {
    // read the sensor value:
    int sensorReading = analogRead(A0);
    // map it to a range from 0 to 100:
    int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
    // set the motor speed:
    if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 100);
    }
    }
    • Like Like x 1
  2. csrealsimracer

    csrealsimracer New Member

    Joined:
    Jan 29, 2016
    Messages:
    25
    Location:
    china
    Balance:
    316Coins
    Ratings:
    +13 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    a lot of work has to be done on this code