Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: Ws 2812b pixels to control Dc motors

  1. #11
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by MartinMueller2003 View Post
    I suggest you use the WeMos R1D1 board. 8266 based but has more of the IO pins available. You could do more than one motor on a single board.
    Thank you for posting this . I just googled the wemos will use them instead .

  2. #12
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,575
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    You are welcome. I have used it in a few projects and it works well. Very Arduino'ish in how it is set up.


    2019 - Just moved into a new home (yet another change of plans). Will be dim but not dark. Too much to do at the new place to leave time for a show.
    https://www.youtube.com/channel/UCyX...ttrsZNARkUce0Q

  3. #13
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    i'd like to control a stepper motor from e1.31 to make a kind of dmx-winch. I'd like absolute control meaning 1 in the channel is position 1 and 254 in the channel is position 254. I tried this half a year ago and got some rudimentary movement. I have to call in my neighbour to help (he's a programmer)....
    Hi kockie
    I have managed to get stepper motors working now with code that can be simply added to the espixel firmware .
    If you are looking for something functional to test with .

    Cheers

  4. #14
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    i'd like to control a stepper motor from e1.31 to make a kind of dmx-winch. I'd like absolute control meaning 1 in the channel is position 1 and 254 in the channel is position 254. I tried this half a year ago and got some rudimentary movement. I have to call in my neighbour to help (he's a programmer)....
    Your post has got me interested in steppers for the hobby . I think this can be done in a roundabout way using 2 rgb channels .

    1 for speed and direction and another for a set position .

    Yet to test .

    Code:
    void loop() {
      // Stepper  Control
      int speed = 0;
      int direction = 1;
      // Get position on PWM_pin
      int position = analogRead(14);
    
      /*
      Values between 562 and 1023 mean forward movement. Speed gets
      mapped from 0 to 100 and direction stays positive. Park_pin will
      stop any movement if HIGH.
      */
      if (position > 562 and digitalRead(4) == HIGH) {
        speed = map(position, 562, 1023, 0, 100);
      }

  5. #15
    Join Date
    Nov 2015
    Location
    The Netherlands
    Posts
    72
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by angus40 View Post
    Hi kockie
    I have managed to get stepper motors working now with code that can be simply added to the espixel firmware .
    If you are looking for something functional to test with .

    Cheers
    iI'm interested for sure!
    Errors for fun only.

  6. #16
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    iI'm interested for sure!
    I am happy to report , you have your winch !!

    forward , reverse .

    on/off-energize and ramp from 0-255

    Simple control via color intensity .


    Code:
    /* 
    Stepper Motor Control
    with L293D ic & 1 x ws2811  pixel boards
    */
    
    #include <Stepper.h>
    
    
    
    
    // Set steps per revolution
    const int stepsPerRevolution = 32;  //<< Set to 1/2 of your stepper's rating if using stepper.h library for normal speed , or increase for faster speeds
    const int PWM_PIN = 14;  // PWM INPUT.   red  channel 
    const int PWM2_PIN =  12;  // PWM INPUT  blue channel      
    
    /* Motor >>>>> in pins 15-5  Pins from motor to L293D
    connection order on ic 4,3,2,1    */  
    Stepper motor1(stepsPerRevolution, 15,13,4,5);
    
    
    void setup() {
     
    
    
        // Initial pin states
        pinMode(PWM_PIN, INPUT); // pin 14 red channel sensor
        pinMode(PWM2_PIN, INPUT); // pin 12 blue channel sensor
        int Bsensor = 0;
    
    void loop() {
        
        }
        // MOTOR 1 CONTROL
        int speed = 0;
        int direction = 1;
      
        int position = analogRead(14);  // forward position sensor 
        int Bsensor = analogRead(12);  // reverse position sensor
      
      
        /*
        Forward steps
        */
        if (position > 0 ) {
        speed = map(position, 0, 1023, 0, 255);        
        }
        /*
        Reverse steps
        */
        if (Bsensor > 0 ) {
        speed = map(position, 0, 1023, 255, 0);      
        direction = -1;
        }
        //  Movement 
        if (speed > 0) {
        motor1.setSpeed(speed);
        motor1.step(direction);
    
      }
    }
    Last edited by angus40; 07-27-2019 at 05:14 AM. Reason: Simplified to 2 input pins for ez control

  7. #17
    Join Date
    Nov 2015
    Location
    The Netherlands
    Posts
    72
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    I am definitely going to try this... when my to-do list is a little shorter.
    Errors for fun only.

  8. #18
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    I just tested in sequencer to verify all is working . Success !

    Initially I tested via espixelStick effects test , this is much different than using a sequencer so results were totally different ,

    In sequencer , 1st channel needs to have sequence data to enable channels 2 and 3 .
    Channel 2 and 3 provide full control base on their respective sequence data's intensity .

    If required , I can do a tutorial on this but I think most will get the idea how this works .

    Thanks for motivating me to pursue this as this will work great for a prop I have in mind .

  9. #19
    Join Date
    Sep 2016
    Posts
    18
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by angus40 View Post
    I just tested in sequencer to verify all is working . Success !

    Initially I tested via espixelStick effects test , this is much different than using a sequencer so results were totally different ,

    In sequencer , 1st channel needs to have sequence data to enable channels 2 and 3 .
    Channel 2 and 3 provide full control base on their respective sequence data's intensity .

    If required , I can do a tutorial on this but I think most will get the idea how this works .

    Thanks for motivating me to pursue this as this will work great for a prop I have in mind .
    will this work to control servo?

    Looking to turn my Wemos D1 min pixelstick into servo controller. would be nice if I can run 4-6 servos off one Wemos and sequence in Vixen3

  10. #20
    Join Date
    Dec 2011
    Posts
    5,798
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    I have not tried with servo yet .

    Here is something you can test with that should work for a servo .
    It could be extended to include more servos I would think .



    Code:
    #include <Servo.h>
    
    Servo myservo;  // create servo object to control a servo
    
    const int PWM14_pin =  14;  //INPUT < your i/o pin 
    int val = 0;    // variable to read the value from the input pin
    
    void setup() {
      myservo.attach(4);  // attaches the servo on pin 4 to the servo object
    }
    
    void loop() {
      val = analogRead(14);            // reads the value of ws 2812b r, g, or b output  ( user connect)
      val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
      myservo.write(val);                  // moves the servo
      delay(100);                           // waits for the servo to arrive , can be modified for speed
    }
    Last edited by angus40; 07-20-2019 at 01:25 AM.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •