Results 1 to 2 of 2

Thread: Wemos d1 mini servo controller

  1. #1
    Join Date
    Oct 2014
    Cleethorpes, England
    Post Thanks / Like

    Default Wemos d1 mini servo controller

    Hi everyone ive been a member for a few years now and most of my knowlegde came from the people here
    I found a piece code a few years ago to control servos with a arduino uno via generic serial and it worked a treat

    but eventually i wanted to make it wireless, initially i used a pi running fpp and asked a lot of questions in the forum
    read a few thousand post and picked a lot of brains

    Then i came across this post

    and "Zero9r" posted the code he had been working on for the Wemos d1 mini
    the code worked well but didnt give me the control i had before so i tried to understand how his code worked
    i started by removing the bits i didnt understand, ok i was left with a blank page but eventually i put my code
    on 1 side of my screen and his on the other and started swapping from one to the other, after a bit of trial and a lot
    of error it worked yeah! so i thought its about time i paid something back for all that i have taken from this forum

    If it helps some thats great i can relax for another couple of years

    Thanks qubie

    #include <ESP8266WiFi.h>
    #include <E131.h> // Copyright (c) 2015 Shelby Merrick
    #include <Servo.h> 
    Servo ch_1_red_Servo_1;
    Servo ch_1_green_Servo_2;
    Servo ch_1_blue_Servo_3;
    Servo ch_2_red_Servo_4;
    Servo ch_2_green_Servo_5;
    Servo ch_2_blue_Servo_6;
    // ***** USER SETUP STUFF *****
    const char ssid[] = "12345678";  // replace with your SSID.
    const char passphrase[] = "abcdefghij"; // replace with your PASSWORD.
    const int universe = 1; // this sets the universe number you are using.
    // this sets the Universe channel number used by the output.
    const int ch_1_red = 0; // the channel number to link to output 1 red.
    const int ch_1_green = 1; // the channel number to link to output 1 green.
    const int ch_1_blue = 2; // the channel number to link to output 1 blue.
    const int ch_2_red = 3; // the channel number to link to output 2 red.
    const int ch_2_green = 4; // the channel number to link to output 2 green.
    const int ch_2_blue = 5; // the channel number to link to output 2 blue.
    int val1;
    int val2;
    int val3;
    int val4;
    int val5;
    int val6;
    E131 e131;
    void setup(){
      ch_1_red_Servo_1.attach(4); // D2
      ch_1_green_Servo_2.attach(5); // D1
      ch_1_blue_Servo_3.attach(12); // D6
      ch_2_red_Servo_4.attach(13); // D7
      ch_2_green_Servo_5.attach(14); // D5
      ch_2_blue_Servo_6.attach(15); // D8
       // set the servos to Mid point 
        /* Choose one to begin listening for E1.31 data */
       e131.begin(ssid, passphrase);               /* via Unicast on the default port */
       //e131.beginMulticast(ssid, passphrase, universe); /* via Multicast for Universe 1 */
    void loop() {
      /* Parse a packet */
      uint16_t num_channels = e131.parsePacket();
      /* Process channel data if we have it */
      if (num_channels) {
      Serial.println("we have data");
        val1 =[ch_1_red];                  
        val1 = map(val1, 0, 255, 90, 45);    //(maps incoming data 0-255 to servo, start at 90 move to 45, swap these 2 numbers around will change direction of servo) 
        ch_1_red_Servo_1.write(val1);        //(Change the 90 to 0 and the 45 to 180 will use full motion of servo) .        
        val2 =[ch_1_green];
        val2 = map(val2, 0, 255, 90, 45);    
        val3 =[ch_1_blue];
        val3 = map(val3, 0, 255, 90, 45);     
        val4 =[ch_2_red];                  
        val4 = map(val4, 0, 255, 90, 45);    
        val5 =[ch_2_green];
        val5 = map(val5, 0, 255, 90, 45);    
        val6 =[ch_2_blue];
        val6 = map(val6, 0, 255, 90, 45);     

  2. #2
    Join Date
    Feb 2009
    Plymouth, MN
    Post Thanks / Like

    Default Re: Wemos d1 mini servo controller

    Nice job, thanks!
    Even though the DIGWDF Store has been closed for two years, it's still awesome!
    User guides, documentation and other files are still free and available for downloading.


Posting Permissions

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