IFTTT Push button instead of Switch button

I followed all the steps for integrating IFTTT with Blynk. I am facing two problems:

  1. I need a push button instead of a switch button. So it only works once (I have to set the button to 0 again to work again) In Blynk this works fine ofcourse. I found a post from @Amantevez which is basically reading the status from the button and set it to 0 again if it is 1.
    This is the piece of code:

int ledPin=4
if (digitalRead(ledPin) == HIGH) {
delay (200);
digitalWrite(ledPin, LOW);

The pin I need is D4 but I cannot get it to work, I tried 0 and 1 instead of High an Low but no success.

Any ideas ?

  1. Blynk is working with DO Button but not with IFTTT. I use Ip instead of DNS.
    Any ideas ?

Thanks in advance

Try modding this code for your needs:

BLYNK_WRITE(V2) // Run this function once when V2 button pressed.
{
  int buttonValue = param.asInt();  // Get status of V2.
  if (buttonValue == 1) {  // If status of V1 is 1 then do stuff in if().
    int buttonValue = 0;  // Set V2 status to 0.
    digitalWrite(ledPin, HIGH); // Turn on LED.
    delay(200); // Wait 20o millis but remember you are holding up the show.
    digitalWrite(ledPin, LOW);  // Turn off LED.
    Blynk.run(); // Run rest of show in-between waiting for this loop.
  }
}
1 Like

I think that’s about the same code that I use. Strange thing is that I defined a Value Display setting widget to track the state of D4 (the pin it is al about). I see the value change from 1 to 0 but the D4 button widget in Blynk stays in a pushed state. Any ideas ?

I find you will need to manually change the button state as it will not automatically align with whatever is happening on the hardware side.

For example, I use this code to activate the accelerometer and flash an RGB according to movement of the phone… while holding down the app button and changing the colour state of said button with Blynk.setProperty().

And you can also change the On, OFF state of the button/switch with Blynk.virtualWrite(Vx, LOW);

//===== Switch for Accelerometer RGB Mode - BLYNK Function =====
BLYNK_WRITE(V8)
{
  AccelSwitch = param.asInt();
  if (AccelSwitch == 0) {
    analogWrite(RedP, 255);  // Turn off RED RGB pin.
    analogWrite(GrnP, 255);  // Turn off GREEN RGB pin.
    analogWrite(BluP, 255);  // Turn off BLUE RGB pin.
    Blynk.setProperty(V8, "color", "#FF0000");
  }
  else {
    Blynk.setProperty(V8, "color", "#00FF00");
  }
}


//===== Accelerometer Widget for RGB - BLYNK Function =====
BLYNK_WRITE(V7) // accelerometer widget, Merge Mode - runs when V8 Switch is on.
{
  while (AccelSwitch == 1)
  {
    int rr = param[0].asInt(); // get a RED channel value.
    int gg = param[1].asInt(); // get a GREEN channel value.
    int bb = param[2].asInt(); // get a BLUE channel value.
    analogWrite(RedP, 255 - rr); // Write to RED RGB pin.
    analogWrite(GrnP, 255 - gg); // Write to GREEN RGB pin.
    analogWrite(BluP, 255 - bb); // Write to BLUE RGB pin.
    AccelSwitch = 0;
    Blynk.syncVirtual(V8);
    Blynk.run();
  }
}

Thanks Gunner, it works so I let the button be.