1. 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!
  2. 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
  3. 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

Question Stepper motor switec X27 and stepper.h library

Discussion in 'DIY peripherals' started by minimus1899, Mar 22, 2021.

  1. minimus1899

    minimus1899 Member

    Joined:
    Mar 7, 2016
    Messages:
    66
    Occupation:
    retired/broken/falling to bit
    Location:
    lincoln
    Balance:
    154Coins
    Ratings:
    +58 / 1 / -0
    My Motion Simulator:
    Arduino
    Okay my lap time in LFS is 15 hours i need help

    ive been at this all day and night and its 10 to 1am and im stuck,.

    i read about this here by RacingMat

    https://www.xsimulator.net/community/threads/driving-diy-cluster-gauges-with-gamedash.5896/

    and well the code and im guessing the library is very old and no good

    im using a L293D h Bridge with RacingMats code and it didnt stop the jutter and the slowness

    so i thorght to hell with it ill use the Stepper.h library arduino comes with.....

    i cant get it to move the gauge it just makes a noise and sometimes locks up like its trying to do something

    here a picture of what i have

    20210322_004207.jpg

    so here is my code i have for the stepper.h library

    Code:
    // D8 to p2, D9 to p7, D10 to p10, D11 to p15. 12V on pin 8 only
    
    #include <Stepper.h>
    
    int stepsPerRevolution = 600;        // Change this to suit the number of steps per revolution for your motor
    byte Rpm;
    
    Stepper MotorRPM(stepsPerRevolution, 8, 9, 10, 11); // initialize the stepper library
    
    
    void setup()
    {
    
      Serial.begin(115200);         
    
    } // End of setup()
    
    
    
    void loop()
    {
      if (Serial.available() > 0)  {
        Rpm = Serial.read();
      }
      MotorRPM.step(map(Rpm, 0, 255, 0, stepsPerRevolution));
    
    }
    Last edited: Mar 22, 2021
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0