BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Led flashing after wifi pairing

Hi everyone

I am using the new blynk.edgent I have paired my esp8266, everything works but the first led of my strip keeps flashing. I would like the led to stop flashing after the association and that I can control the entire strip by adding my code. Where should I go to look in the blynk.edgent code? I am not an expert and I do not understand where the section controls the indication LEDs

Thank you

Best Regards

You are creating multiple topics for the same issues. This way your topic will be closed or removed. Stick to one topic until resolved. And we cannot have a track on what you have done so far with others ideas.

Post your sketch properly formatted. Did you use the function that was used by the library that I mentioned ?

Hi

With Pete i removed old post because is not good
Now i have only this

Best Regards

Hi everyone

maybe I found the line to correct but if I remove it it doesn’t work anymore, I would like that once connected the led strip is completely off (at this moment it flashes) and that I can control the strip from sliders or zebra.

the line is this:
case MODE_RUNNING: return waveLED(COLOR_WHITE, 5000);

in this code:

switch (currState) {
    case MODE_RESET_CONFIG:
    case MODE_WAIT_CONFIG:       return beatLED(COLOR_MAGENTA,    (int[]){ 50, 500 });
    case MODE_CONFIGURING:       return beatLED(COLOR_WHITE,    (int[]){ 200, 200 });
    case MODE_CONNECTING_NET:    return beatLED(COLOR_BLUE,   (int[]){ 50, 500 });
    case MODE_CONNECTING_CLOUD:  return beatLED(COLOR_BLYNK,   (int[]){ 100, 100 });
    case MODE_RUNNING:           return waveLED(COLOR_WHITE,   5000);
    case MODE_OTA_UPGRADE:       return beatLED(COLOR_MAGENTA, (int[]){ 50, 50 });
    default:                     return beatLED(COLOR_RED,     (int[]){ 80, 100, 80, 1000 } );

Thank you

Best Regards

Posting parts of the code will not help !! How can we know whats happening in the rest of the code ? You did not follow what i said. Trying random stuff, editing .h files will only lead to more complicated errors n random errors.

Nobody can help you this way without knowing whats there in the code…

Try to follow what members say n try to follow it…

Hi everyone

I apologize Madhukesh I’m just trying to solve the problem by trying, I thought that writing in the “blynk 2.0” to someone in the forum had had the same problem and could suggest something. I try to be clearer. I am using the new blynk.edgent and in the example the developers have inserted the part of code called “Indicator.h” which makes a led blink when blynk joins the wifi network. I am trying to figure out how to make the led stop blinking once blynk is connected, below is the code that should do this. I ask the moderators a favor if it is not the right section to ask for this information to suggest me where I should go.

Below is the code where the flashing led should be

#if defined(BOARD_LED_PIN_WS2812)
  #include <Adafruit_NeoPixel.h>    // Library: https://github.com/adafruit/Adafruit_NeoPixel

  Adafruit_NeoPixel rgb = Adafruit_NeoPixel(1, BOARD_LED_PIN_WS2812, NEO_GRB + NEO_KHZ800);
#endif

void indicator_run();

#if !defined(BOARD_LED_BRIGHTNESS)
#define BOARD_LED_BRIGHTNESS 255
#endif

#if defined(BOARD_LED_PIN_WS2812) || defined(BOARD_LED_PIN_R)
#define BOARD_LED_IS_RGB
#endif

#define DIMM(x)    ((x)*(BOARD_LED_BRIGHTNESS)/255)
#define RGB(r,g,b) (DIMM(r) << 16 | DIMM(g) << 8 | DIMM(b) << 0)

class Indicator {
public:

  enum Colors {
    COLOR_BLACK   = RGB(0x00, 0x00, 0x00),
    COLOR_WHITE   = RGB(0xFF, 0xFF, 0xE7),
    COLOR_BLUE    = RGB(0x0D, 0x36, 0xFF),
    COLOR_BLYNK   = RGB(0x2E, 0xFF, 0xB9),
    COLOR_RED     = RGB(0xFF, 0x10, 0x08),
    COLOR_MAGENTA = RGB(0xA7, 0x00, 0xFF),
  };

  Indicator() {
    m_Counter = 0;
    initLED();
  }

  uint32_t run() {
    State currState = BlynkState::get();

    // Reset counter if indicator state changes
    if (m_PrevState != currState) {
      m_PrevState = currState;
      m_Counter = 0;
    }

    if (g_buttonPressed) {
      if (millis() - g_buttonPressTime > BUTTON_HOLD_TIME_ACTION)     { return beatLED(COLOR_WHITE,   (int[]){ 100, 100 }); }
      if (millis() - g_buttonPressTime > BUTTON_HOLD_TIME_INDICATION) { return waveLED(COLOR_WHITE,   1000); }
    }
    switch (currState) {
    case MODE_RESET_CONFIG:
    case MODE_WAIT_CONFIG:       return beatLED(COLOR_MAGENTA,    (int[]){ 50, 500 });
    case MODE_CONFIGURING:       return beatLED(COLOR_WHITE,    (int[]){ 200, 200 });
    case MODE_CONNECTING_NET:    return beatLED(COLOR_BLUE,   (int[]){ 50, 500 });
    case MODE_CONNECTING_CLOUD:  return beatLED(COLOR_BLYNK,   (int[]){ 100, 100 });
    case MODE_RUNNING:           return waveLED(COLOR_WHITE,   5000);
    case MODE_OTA_UPGRADE:       return beatLED(COLOR_MAGENTA, (int[]){ 50, 50 });
    default:                     return beatLED(COLOR_RED,     (int[]){ 80, 100, 80, 1000 } );
    }
  }

protected:

  /*
   * LED drivers
   */

#if defined(BOARD_LED_PIN_WS2812)  // Addressable, NeoPixel RGB LED

  void initLED() {
    rgb.begin();
    setRGB(COLOR_BLACK);
  }

  void setRGB(uint32_t color) {
    rgb.setPixelColor(0, color);
    rgb.show();
  }

#elif defined(BOARD_LED_PIN_R)     // Normal RGB LED (common anode or common cathode)

  void initLED() {
    pinMode(BOARD_LED_PIN_R, OUTPUT);
    pinMode(BOARD_LED_PIN_G, OUTPUT);
    pinMode(BOARD_LED_PIN_B, OUTPUT);
  }

  void setRGB(uint32_t color) {
    uint8_t r = (color & 0xFF0000) >> 16;
    uint8_t g = (color & 0x00FF00) >> 8;
    uint8_t b = (color & 0x0000FF);
    #if BOARD_LED_INVERSE
    analogWrite(BOARD_LED_PIN_R, BOARD_PWM_MAX - r);
    analogWrite(BOARD_LED_PIN_G, BOARD_PWM_MAX - g);
    analogWrite(BOARD_LED_PIN_B, BOARD_PWM_MAX - b);
    #else
    analogWrite(BOARD_LED_PIN_R, r);
    analogWrite(BOARD_LED_PIN_G, g);
    analogWrite(BOARD_LED_PIN_B, b);
    #endif
  }

#elif defined(BOARD_LED_PIN)       // Single color LED

  void initLED() {
    pinMode(BOARD_LED_PIN, OUTPUT);
  }

  void setLED(uint32_t color) {
    #if BOARD_LED_INVERSE
    analogWrite(BOARD_LED_PIN, BOARD_PWM_MAX - color);
    #else
    analogWrite(BOARD_LED_PIN, color);
    #endif
  }

#else

  #warning Invalid LED configuration.

#endif

  /*
   * Animations
   */

  uint32_t skipLED() {
    return 20;
  }

#if defined(BOARD_LED_IS_RGB)

  template<typename T>
  uint32_t beatLED(uint32_t onColor, const T& beat) {
    const uint8_t cnt = sizeof(beat)/sizeof(beat[0]);
    setRGB((m_Counter % 2 == 0) ? onColor : (uint32_t)COLOR_BLACK);
    uint32_t next = beat[m_Counter % cnt];
    m_Counter = (m_Counter+1) % cnt;
    return next;
  }

  uint32_t waveLED(uint32_t colorMax, unsigned breathePeriod) {
    uint8_t redMax = (colorMax & 0xFF0000) >> 16;
    uint8_t greenMax = (colorMax & 0x00FF00) >> 8;
    uint8_t blueMax = (colorMax & 0x0000FF);

    // Brightness will rise from 0 to 128, then fall back to 0
    uint8_t brightness = (m_Counter < 128) ? m_Counter : 255 - m_Counter;

    // Multiply our three colors by the brightness:
    redMax *= ((float)brightness / 128.0);
    greenMax *= ((float)brightness / 128.0);
    blueMax *= ((float)brightness / 128.0);
    // And turn the LED to that color:
    setRGB((redMax << 16) | (greenMax << 8) | blueMax);

    // This function relies on the 8-bit, unsigned m_Counter rolling over.
    m_Counter = (m_Counter+1) % 256;
    return breathePeriod / 256;
  }

#else

  template<typename T>
  uint32_t beatLED(uint32_t, const T& beat) {
    const uint8_t cnt = sizeof(beat)/sizeof(beat[0]);
    setLED((m_Counter % 2 == 0) ? DIMM(BOARD_PWM_MAX) : 0);
    uint32_t next = beat[m_Counter % cnt];
    m_Counter = (m_Counter+1) % cnt;
    return next;
  }

  uint32_t waveLED(uint32_t, unsigned breathePeriod) {
    uint8_t brightness = (m_Counter < 128) ? m_Counter : 255 - m_Counter;

    setLED(BOARD_PWM_MAX * (DIMM((float)brightness) / (BOARD_PWM_MAX/2)));

    // This function relies on the 8-bit, unsigned m_Counter rolling over.
    m_Counter = (m_Counter+1) % 256;
    return breathePeriod / 256;
  }

#endif

private:
  uint8_t m_Counter;
  State   m_PrevState;
};

Indicator indicator;

/*
 * Animation timers
 */

#if defined(USE_TICKER)

  #include <Ticker.h>

  Ticker blinker;

  void indicator_run() {
    uint32_t returnTime = indicator.run();
    if (returnTime) {
      blinker.attach_ms(returnTime, indicator_run);
    }
  }

  void indicator_init() {
    blinker.attach_ms(100, indicator_run);
  }

#elif defined(USE_TIMER_ONE)

  #include <TimerOne.h>

  void indicator_run() {
    uint32_t returnTime = indicator.run();
    if (returnTime) {
      Timer1.initialize(returnTime*1000);
    }
  }

  void indicator_init() {
    Timer1.initialize(100*1000);
    Timer1.attachInterrupt(indicator_run);
  }

#elif defined(USE_TIMER_THREE)

  #include <TimerThree.h>

  void indicator_run() {
    uint32_t returnTime = indicator.run();
    if (returnTime) {
      Timer3.initialize(returnTime*1000);
    }
  }

  void indicator_init() {
    Timer3.initialize(100*1000);
    Timer3.attachInterrupt(indicator_run);
  }

#else

  #warning LED indicator needs a functional timer!

  void indicator_run() {}
  void indicator_init() {}

#endif

thank you

Best Regards

Hi

Nobody can help me?

Regards

This is responsible for the blinking i guess. You need to modify this part to stop blinking. Or you can delete the indicator.h file and edit the rest of the code.

Right now i am hospitalised, so i am not in a position to think of any possible solutions.

:open_mouth: hope it’s nothing too serious!

Pete.

Meniscus injury. So i am getting a surgery :sob:
Thank you for your concern.

Ouch! You have my sympathy.
Playing football by any chance?

Pete.

No way !! but it this pains like hell !! I wish no one should ever exp this pain !! :pleading_face:

You need some better drugs :crazy_face:

Pete.

1 Like

Hi Madhukesh
I hope you recover as soon as possible. I try to remove the indicator.h file but the most important thing is that you get well as soon as possible. See you soon

get well soon madhukesh sir

@fabridelo @VIGHNESHNS2008

Even though we are totally strangers i am amazed to see the care you people show.

I am really grateful for the concern you guys are showing towards me !! This makes me feel much better….

This is the power of BLYNK FORUM / FAMILY
We not only get/share knowledge but also Care n Concern :heart::heart::heart:

2 Likes

:100: agree

Hi everyone

I delete the indicator.h file and edit the rest of the code.
That’s fine for now but I’ll try to make a custom indicator.h file.
For now it is solved. How do you close the post?

Thank you

Best Regards