Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Esp GPIO

  1. #11
    Join Date
    Dec 2011
    Location
    UK S80 postcode
    Posts
    1,397
    Post Thanks / Like

    Default Re: Esp GPIO

    Hi, I’m sorry I’ve not been about much this week my lad goes to university on Saturday so my focus has been on family stuff. It looks like you are the top side of this, as the saying goes there is more than one way to skin a cat. To offer another methodology:
    Instead of using
    Code:
    pinMode(pin, OUTPUT);
    Which outputs 3.3V for when digitalWrite(pin, 1023) is asked for, or digitalWrite(pin, (map(255, 0, 255, 0, 1023))); and 0V for value 0. Use
    Code:
    pinMode(pin, OUTPUT_OPEN_DRAIN);
    This will make the pin open circuit for value 0 and fully conductive for digitalWrite(pin, 1023); which effectively inverts the pin for common anode LEDs. You can then use the original statement
    Code:
    digitalWrite(input_1_blue, e131.data[channel_1_blue]);
    As a note: The ESP8266 output (or OPEN_DRAIN) can only handle 12mA unlike the Adrunio Mega, Uno and Mini that have outputs rated at about 35mA and they are only rated at 3.3V. If you power the ‘dumb’ LEDs from 3.3V they should work and it should keep the power at about the acceptable level but only be 50% of the 5V level.

  2. #12
    Join Date
    Dec 2011
    Posts
    5,872
    Post Thanks / Like

    Default Re: Esp GPIO

    Well the only two solutions that function correctly / play nicely .

    This as Martin suggested worked but for analogWrite only and no dimming

    Code:
    analogWrite(output_1_red, (e131.data[channel_1_red -1] > 0)? 0 : 1023);
    And Joe's code for digitalWrite
    Code:
    #define Bit_Of_Magic(V) (V ? 0 : 1)
    
    digitalWrite(output_1_red, Bit_Of_Magic(e131.data[channel_1_red -1] > 0)? 0 : 1023);
    No Dimming though
    Last edited by angus40; 09-12-2019 at 08:41 PM.

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

    Default Re: Esp GPIO

    Quote Originally Posted by Barnabybear View Post
    Hi, I’m sorry I’ve not been about much this week my lad goes to university on Saturday so my focus has been on family stuff. It looks like you are the top side of this, as the saying goes there is more than one way to skin a cat. To offer another methodology:
    Instead of using
    Code:
    pinMode(pin, OUTPUT);
    Which outputs 3.3V for when digitalWrite(pin, 1023) is asked for, or digitalWrite(pin, (map(255, 0, 255, 0, 1023))); and 0V for value 0. Use
    Code:
    pinMode(pin, OUTPUT_OPEN_DRAIN);
    This will make the pin open circuit for value 0 and fully conductive for digitalWrite(pin, 1023); which effectively inverts the pin for common anode LEDs. You can then use the original statement
    Code:
    digitalWrite(input_1_blue, e131.data[channel_1_blue]);
    As a note: The ESP8266 output (or OPEN_DRAIN) can only handle 12mA unlike the Adrunio Mega, Uno and Mini that have outputs rated at about 35mA and they are only rated at 3.3V. If you power the ‘dumb’ LEDs from 3.3V they should work and it should keep the power at about the acceptable level but only be 50% of the 5V level.
    Family First

    Thank you for your reply

    I tested this also with no joy
    The output_open_drain does not appear to have function as it does not highlight .


    .

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

    Default Re: Esp GPIO

    If you find yourself in the same situation as I with rgb and proper output control using Barnabybears's DC/RGB for Wemos sketch , read on .

    Here is code that works for both digitalWrite and analogWrite and is the easiest solution that worked for me .

    I played with and kicked this around for hours not knowing what the heck I was doing

    With much thanks to Joe and Martin ,I finally had a direction to look and tires to kick .

    The following is not etched in stone but works great for me with no other code needed.
    on and off no dimming ..........sorry.

    Code:
    digitalWrite(output_1_red, ((e131.data[channel_1_red -1]) <= 127 ) ? 1023 : 0);
    analogWrite(output_1_red, ((e131.data[channel_1_red -1]) <= 127 ) ? 1023 : 0);

Page 2 of 2 FirstFirst 12

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
  •