Email when virtual pin is pressed

Well, start by breaking your needs into steps and lay it out psudocode style…

  • Check for button/switch press
  • determine it’s state (ON or OFF)
  • open/close lock depending on state
  • send email as required
BLYNK_WRITE(V0) {  // This function is called eac time a Button, set for Switch Mode, on virtual Pin V0, is pressed
  if(param.asInt()==1) { // If button switch is ON
  // Open lock
  // send email saying unlocked
  } else { // If button switch is OFF
    // Close lock
    // send email saying locked
    }
}

But since email can’t be sent so frequently… you need to add in additional logic and timers.

image

  • “Clear Flag” set for 5+ seconds before OK
  • If need to send email, check if clear flag is OK
  • If clear flag is OK, send email
  • if clear flag is NOT OK wait until OK to send email, then reset flag

Now this one can be done in a few different ways… BlynkTimer, logic flags (if x==1 then do something, else don’t do something), or a combo of both.

Lay out your goals/steps/problems… then start work on the first problem, but substitute sending the email with sending a serial print message instead (no limitations there :slight_smile: )… then work on the next step, and so on.