hi, i wrote an usermod with the v2 template. but afte i flash the file, the leds working interupted and i get every second/third click at the color change at the UI an error to connect.
can somebody see in my code why?
its an simple code to drive an stepper motor. the motor works correct…only the leds not.
thank you
#pragma once
#include "wled.h"
#include <AccelStepper.h>
const int stepsPerRevolution = 64; // change this to fit the number of steps per revolution
// ULN2003 Motor Driver Pins
#define IN1 19
#define IN2 18
#define IN3 5
#define IN4 17
// initialize the stepper library
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);
//This is an empty v2 usermod template. Please see the file usermod_v2_example.h in the EXAMPLE_v2 usermod folder for documentation on the functions you can use!
class speedstep : public Usermod {
private:
public:
void setup()
{
// Change these to suit your stepper if you want
stepper.setMaxSpeed(150);
stepper.setAcceleration(100);
}
void loop() {
stepper.moveTo(500);
while (stepper.currentPosition() != 300) // Full speed up to 300
stepper.run();
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
// Now stopped after quickstop
// Now go backwards
stepper.moveTo(-500);
while (stepper.currentPosition() != 0) // Full speed basck to 0
stepper.run();
stepper.stop(); // Stop as fast as possible: sets new target
stepper.runToPosition();
// Now stopped after quickstop
}
};