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

[SOLVED] GPS TRIGGER can use as a pin TRIGGER can use as a pin restriction


#1

GPS TRIGGER can use as a pin restriction
ej I want to pin restriction for one area and nobody can turn on the pin out to that area


#2

If I understand your question, you want to limit someones ability to “do something”, for example; activate a button, slider or switch (in the app) while the phone or tablet is in a specific area?

If so, then I belive you can use the GPS trigger, attached to a virtual pin, that then acts like a flag for another programmed function.

Perhaps like this:

BLYNK_WRITE(V0)   // GPS Trigger
{
  GPSflag = param.asInt();  // Set the flag to 1 or 0
}


BLYNK_WRITE(V1)   // Button that does something if GPSflag is 1
{
  if (GPSflag == 1)   // Check flag
  {
    //  Do something if flag is 1
  }
  else {
    //  Do something else and/or give feedback that something is not allowed in this location
  }
}

#3

Yes I will try that for a limit
Thank you


#4

@Jairo30 you could use the Terminal widget for users to enter a pin number and then include an if statement around every other Widget. If the pin is correct the Widget will run and if it isn’t no action will be taken.


#5

thank for you replay but what I want to do is set a limit for a button, slider or switch (in the app) while the phone or tablet is in a specific area


#6

what kind of limit?


#7

a limit for a specific area with GPS TRIGGER
limit can you use the button just in specific area, like the garage door cannot open by mistake for a different location.


#8

Hi, I am looking @ the same concept, Jairo30 have you got a solution


#9

hello I been working in others project and I never take time to resolve this issue.
If you find more information please sharing with me this option is real good for security and void miss press buttons.
thank you


#10

@Dalmine007 If you haven’t already, please take note of the timestamps when posting to older topics.

My first post already gave a solution to this “issue”; set a flag that gets set active only when the App is in a specific GPS determined area. Then with code, check that flag whenever the specified widget controls are activated… if flag active (in area), continue with action, if flag inactive (out of area) ignore command.

Basic Boolean Logic. https://www.arduino.cc/en/Reference/Boolean


#11

Hi Sir, thanks for the help so far, I am having a small issue now. Getting the following error when uploading sketch

exit status 1
‘GPSflag’ was not declared in this scope

BLYNK_WRITE(V0)   // GPS Trigger
{
  GPSflag = param.asInt();  // Set the flag to 1 or 0
}


BLYNK_WRITE(V1)   // Button that does something if GPSflag is 1
{
  if (GPSflag == 1)   // Check flag
  {
    //  Do something if flag is 1
    digitalWrite(13, high)
    
  }
  else {
    //  Do something else and/or give feedback that something is not allowed in this location
     digitalWrite(13, low)
  }
}

void setup()

#12

Just as the error stated, you need to declare that variable, either globally or locally - https://www.arduino.cc/en/Reference/Scope

e.g. set GPSflag as a local integer.

int GPSflag = param.asInt(); // Set the flag to 1 or 0


#13

@Dalmine007 as you are using the GPSflag in more than one function it will need to be declared as a global variable.


#14

Thanks Guys it’s working perfectly now

I am just posting final code as reference for anyone.

int GPSflag;

BLYNK_WRITE(V0)   // GPS Trigger
{
  GPSflag = param.asInt();  // Set the flag to 1 or 0
}


BLYNK_WRITE(V1)   // Button that does something if GPSflag is 1
{
  pinMode(13, OUTPUT);
  if (GPSflag == 1)   // Check flag
  {
    //  Do something if flag is 1
   // pinMode(13, OUTPUT);
    digitalWrite(13, HIGH);
    delay(500); 
    digitalWrite(13, LOW);
  }
  else {
    //  Do something else and/or give feedback that something is not allowed in this location
     digitalWrite(13, LOW);
  }
}

void setup()
{
  // Debug console
  SwSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

void loop()
{
  Blynk.run();
}

GPS Trigger not working
#15

Thanks for posting your code example for others as reference. However, I’d like to send a friendly reminder that it’s also very helpful for other viewers if you format your code according to the guidelines on this page: [README] Welcome to Blynk Community! (you only have to tap the ` key 3 time before, and after, your pasted code snippet). So, please don’t take offense, and want to express my sincere thanks to everyone who participated in this thread, as I’m looking at adding some geo-location restrictions to my project behavior as well. :relaxed:


#16

I fixed your formatting… again… please don’t post unformatted code double-oh or you might lose your license :wink: