Strobe Light with Blynk and Simple Timer Library

Hello,

I have several led strips that I currently control with Blynk.

Now I’m trying to go further, and make them do the strobe effect with a virtual pin.

I have used the Simple Timer library to switch the led strips state with a push button, and I was thinking if it could be possible to use this same library for doing this.

Thank You.

Check out the STROBOSCOPE example in the SKETCH BUILDER section. Might be just what you are looking for.

1 Like

I recently did something similar with pulsing a relay. Try this concept: Producing pulses Just adjust the times and flash the LEDS instead of the relay.

// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1)  // Virtual button on V1 to activate relay pulses
{
  int RLY = param.asInt();
  if (RLY == 1)
  {
    timerV1.setTimer(500, RelayON, 3);  // Pulse Relay ON routine three times in 500ms
  } 
}

void RelayON()
{
  digitalWrite(2, HIGH); // Activate relay
  timerV1.setTimer(100, RelayOFF, 1);  // RunRelay OFF routine once in 100ms
}

void RelayOFF()
{
  digitalWrite(2, LOW); // deactivate relay
}
// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1)  // Virtual button on V1 to activate relay pulses
{
  int RLY = param.asInt();
  if (RLY == 1)
  {
    timerV1.setTimer(500, RelayON, 3);  // Pulse Relay ON routine three times in 500ms
  } 
}

void RelayON()
{
  digitalWrite(2, HIGH); // Activate relay
  timerV1.setTimer(100, RelayOFF, 1);  // RunRelay OFF routine once in 100ms
}

void RelayOFF()
{
  digitalWrite(2, LOW); // deactivate relay
}

let update this a bit…

// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1) { // Virtual button on V1 to activate relay pulses
  if (param.asInt())  {
    timerV1.setTimer(500, [](){
      digitalWrite(2, HIGH); // Activate relay
      timerV1.setTimer(100, [](){
        digitalWrite(2, LOW); // deactivate relay
      }, 1);  // RunRelay OFF routine once in 100ms
    }, 3);  // Pulse Relay ON routine three times in 500ms
  } 
}

Sooo nice and compact… but now I can’t understand it :wink:

My “discovery” (more like tripping over a rock while banging sticks together) has created a coding monster :smiley:

You actually have no idea… I spent a good 2 days updating ALL the codes to the new format!! :joy::heart_eyes:

1 Like

I’ll check it.

Thank You so much!.

It looks pretty well,

I try that code tomorrow, because it’s for an Arduino shield that I don’t have here.

I’ll tell you something :slight_smile:

Thank you very much.

By now I have just implemented it into my code.

1 Like